Jump to content

Html

Members
  • Posts

    640
  • Joined

  • Last visited

Everything posted by Html

  1. Html

    Table has error

    I tried editing the files to remove the subject, once it gets to process.php no loading. All I did was remove subject and anything with it from all the files. Including removing the subject from the db. Just that small change which I think I've done correctly, and it doesn't work.😥 I also was able to view example files from leaning php book, I really need the Learn php 7 easy steps kind of books, 😉 even though they aren't as informative, very simple. <?php $page_title = 'forum' include('includes/header.html'); function fail($str) { echo"<p>Please enter a $str.</p>"; echo '<p><a href="post.php">Post message</a>'; include('includes/header.html'); exit(); } if( isset( $_POST[ 'message' ] ) ) { if ( !empty( trim( $_POST[ 'first_name' ] ) ) ) { $first_name = addslashes( $_POST[ 'first_name' ] ) ; } else { fail( 'First Name' ) ; } if ( !empty( trim( $_POST[ 'last_name' ] ) ) ) { $last_name = addslashes( $_POST[ 'last_name' ] ) ; } else { fail( 'Last Name' ) ; } if ( !empty( trim( $_POST[ 'message' ] ) ) ) { $message = addslashes( $_POST[ 'message' ] ) ; } else { fail( 'Message' ) ; } require ( '/connect_db.php' ) ; $sql = "INSERT INTO forum (first_name,last_name,message,post_date) VALUES ('$first_name', '$last_name', '$message', NOW() )" ; $result = mysqli_query( $dbc, $sql ) ; if (mysqli_affected_rows($dbc) != 1) { echo '<p>Error</p>'.mysqli_error($dbc); mysqli_close( $dbc ) ; } else { mysqli_close( $dbc ) ; header('Location: forum.php') ; } } ?> <?php $page_title = 'PHP Process Error' ; include ( 'includes/header.html' ) ; function fail( $str ) { echo "<p>Please enter a $str.</p>"; echo '<p><a href="post.php">Post Message</a>' ; include ( 'includes/footer.html' ) ; exit(); } if( isset( $_POST[ 'message' ] ) ) { if ( !empty( trim( $_POST[ 'first_name' ] ) ) ) { $first_name = addslashes( $_POST[ 'first_name' ] ) ; } else { fail( 'First Name' ) ; } if ( !empty( trim( $_POST[ 'last_name' ] ) ) ) { $last_name = addslashes( $_POST[ 'last_name' ] ) ; } else { fail( 'Last Name' ) ; } if ( !empty( trim( $_POST[ 'message' ] ) ) ) { $message = addslashes( $_POST[ 'message' ] ) ; } else { fail( 'Message' ) ; } require ( 'connect_db.php' ) ; $sql = "INSERT INTO forum (first_name,last_name,message,post_date) VALUES ('$first_name', '$last_name', '$message', NOW() )" ; $result = mysqli_query( $dbc, $sql ) ; if (mysqli_affected_rows($dbc) != 1) { echo '<p>Error</p>'.mysqli_error($dbc); mysqli_close( $dbc ) ; } else { mysqli_close( $dbc ) ; header('Location: forum.php') ; } } ?> <?php $page_title='php post message'; include('includes/header.html'); echo'<form action="process.php" method="POST" accept-charset=""uft-8"> First Name:<input name="first_name" type="text"> Last Name:<input name="last_name" type="text"> <p>Message:<br> <textarea name="message" rows"5" cols="50"> </textarea></p> <p><input type="submit" value="Submit"></p> </form>'; echo '<p> <a href="forum.php">Forum</a></p>'; include('includes/footer.html'); ?> I've removed from forum, post, and process subject named as I stated. The error is column 1 Works okay now. I guess it was just a server side process error.
  2. <?php /* Main page with two forms: sign up and log in */ require 'connect_db.php'; session_start(); ?> <!DOCTYPE html> <html> <head> <title>-Sign-Up/Login Form</title> <?php include 'css/css.html'; ?> </head> <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (isset($_POST['login'])) { //user logging in require 'login.php'; } elseif (isset($_POST['register'])) { //user registering require 'proces.php'; } } ?> <body> <img src="header20182.jpg"> <center> <img src="userscopy.jpg"> </center> <div class="form"> <ul class="tab-group"> <li class="tab"><a href="#signup">Sign Up</a></li> <li class="tab active"><a href="#login">Log In</a></li> </ul> <div class="tab-content"> <div id="login"> <h1>Welcome!</h1> <form action="proces.php" method="post" autocomplete="off"> <div class="field-wrap"> <label> Email Address<span class="req">*</span> </label> <input type="email" required autocomplete="off" name="email"/> </div> <div class="field-wrap"> <label> Password<span class="req">*</span> </label> <input type="password" required autocomplete="off" name="password"/> </div> <p class="forgot"><a href="forgot.php">Forgot Password?</a></p> <button class="button button-block" name="login" />Log In</button> </form> </div> <div id="signup"> <h1>Create an account today! </h1> <form action="proces.php" method="post" autocomplete="off"> <div class="top-row"> <div class="field-wrap"> <label> First Name<span class="req">*</span> </label> <input type="text" required autocomplete="off" name='firstname' /> </div> <div class="field-wrap"> <label> Last Name<span class="req">*</span> </label> <input type="text"required autocomplete="off" name='lastname' /> </div> </div> <div class="field-wrap"> <label> Email Address<span class="req">*</span> </label> <input type="email"required autocomplete="off" name='email' /> </div> <div class="field-wrap"> <label> Six to eight character Password<span class="req">*</span> </label> <input type="password"required autocomplete="off" name='password'/> </div> <button type="submit" class="button button-block" name="register" />Register</button> </form> </div> </div><!-- tab-content --> </div> <!-- /form --> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script> <a href="privacy.html" target="_blank"><img src="privacy.jpg"> <img src="bottomheader.jpg"> </body> </html> Okay I'm trying to get this index page from the old files to work with a new register.php, which is from the php 7 book, So far the page goes to it after registration but recorded data in the db. Not sure if this was the correct way but consider it works to post data, seemed like the next best step. so proces.php <?php $page_title = 'PHP Process' ; include ( 'includes/header.html' ) ; function fail( $str ) { echo "<p>Please enter a $str.</p>"; echo '<p><a href="post.php">Post Message</a>' ; include ( 'includes/footer.html' ) ; exit(); } if( isset( $_POST[ 'message' ] ) ) { if ( !empty( trim( $_POST[ 'first_name' ] ) ) ) { $first_name = addslashes( $_POST[ 'first_name' ] ) ; } else { fail( 'First Name' ) ; } if ( !empty( trim( $_POST[ 'last_name' ] ) ) ) { $last_name = addslashes( $_POST[ 'last_name' ] ) ; } else { fail( 'Last Name' ) ; } if ( !empty( trim( $_POST[ 'email' ] ) ) ) { $subject = addslashes( $_POST[ 'email' ] ) ; } else { fail( 'email' ) ; } if ( !empty( trim( $_POST[ 'password' ] ) ) ) { $subject = addslashes( $_POST[ 'password' ] ) ; } else { fail( 'password' ) ; } require ( 'connect_db.php' ) ; $sql = "INSERT INTO users (first_name,last_name,email,password) VALUES ('$first_name', '$last_name', '$email', '$password' )" ; $result = mysqli_query( $dbc, $sql ) ; if (mysqli_affected_rows($dbc) != 1) { echo '<p>Error</p>'.mysqli_error($dbc); mysqli_close( $dbc ) ; } else { mysqli_close( $dbc ) ; header('Location: profile.php') ; } } So profile should be next, but only loads the includes header page heading.
  3. Html

    Table has error

    Okay, I copied the full, and pasted it in, now I get a process error, that is all that loads, the page header is also displayed. So something is working, no db info recorded. What could it? All the files are in the same folder, except for the includes folder files. Yes it was simply the forward slash I forgot about, I noticed that php code must be spaced. I'm a step closer to my goal of a working system with this. Now using what I had downloaded, and trying to change it to work with this code.😩 Thanks for the responses.
  4. Html

    Table has error

    My last file to do is process, filled in the details, only a blank page loads, and no data entered into the db. <?php $page_title = 'forum' include('includes/header.html'); function fail($str) { echo"<p>Please enter a $str.</p>"; echo '<p><a href="post.php">Post message</a>'; include('includes/header.html'); exit(); } if( isset( $_POST[ 'message' ] ) ) { if ( !empty( trim( $_POST[ 'first_name' ] ) ) ) { $first_name = addslashes( $_POST[ 'first_name' ] ) ; } else { fail( 'First Name' ) ; } if ( !empty( trim( $_POST[ 'last_name' ] ) ) ) { $last_name = addslashes( $_POST[ 'last_name' ] ) ; } else { fail( 'Last Name' ) ; } if ( !empty( trim( $_POST[ 'subject' ] ) ) ) { $subject = addslashes( $_POST[ 'subject' ] ) ; } else { fail( 'Subject' ) ; } if ( !empty( trim( $_POST[ 'message' ] ) ) ) { $message = addslashes( $_POST[ 'message' ] ) ; } else { fail( 'Message' ) ; } require ( '/connect_db.php' ) ; $sql = "INSERT INTO forum (first_name,last_name,subject,message,post_date) VALUES ('$first_name', '$last_name','$subject', '$message', NOW() )" ; $result = mysqli_query( $dbc, $sql ) ; if (mysqli_affected_rows($dbc) != 1) { echo '<p>Error</p>'.mysqli_error($dbc); mysqli_close( $dbc ) ; } else { mysqli_close( $dbc ) ; header('Location: forum.php') ; } } ?>
  5. Html

    Table has error

    I am using Infinityfree which is very much the same as Advancedfree, infinityfree is Arizonan based from the information available. But yes, I typed in the msql server address, and the mysql username, password, and database which has the created forum table that I used from the above post. I had trouble with this host using the example files I downloaded, and edited and that didn't work on there service, but did work on Advancedfree and Heartinternet, the latter being paid. I did inquire on their forum, and an Admin was upset about me complaining, if that rubbish worked on those two hosts why this host so particular, could be that they have very over protective system. Yes, there is a password which is not the same as the user login, that was same as Heart. It seemed obvious with Heart than with this. Okay so far looks like this is up and running.
  6. Html

    Table has error

    Right okay then, I did think that may be there was a comma out of place, now a new error has displayed on line 3, the user has been denied.
  7. Html

    Table has error

    I tried removing the bracket at the end, only then causes a T_logical error on line 4, and if I do remove another from line 4. You'll have to point to it, because I haven't a clue.
  8. Html

    Table has error

    <?php $dbc = mysqli_connect( 'localhost' , 'mike' , 'easysteps' , 'website_db' ) OR die( mysqli_connect_error() ) ; mysqli_set_charset( $dbc , 'utf8' ) ; This is from the files you linked to, <?php $dbc= mysqli_connect( 'server', 'user', 'pass', 'db', ) OR die ( mysqli_connect_error() ); mysqli_set_charset($dbc,'utf-8');
  9. Html

    Table has error

    mysqli_connect('mysqlserverlink','user','pass','db',) This is for connect_db Parse error: syntax error, unexpected ')' line 3
  10. Html

    Table has error

    They are all in htdocs, there is an incudes folder with header, and footer html, with a <p> tag each. That is it. I see, I didn't know about that, I couldn't of guessed. Now line 3 is the problem, I thought may the ) was the problem as it states, no change. Ah I see, so there are example files, could it be the spacing of the code? n ) and so on?
  11. Html

    Table has error

    Other than the missing i, what else? That isn't the solution. blah blah directory of free web host.
  12. Html

    Table has error

    That is after the trying the create_forum page, line 5 it also states. mysql_set_charset($dbc, 'utf-8');
  13. Html

    Table has error

    Well there is no includes folder or footer.html. There is no tutorial on that. I guess I'll have to just try something.
  14. Html

    Table has error

    Ah, I see. I tried editing both pages, nothing. <?php $page_title = 'forum' include('includes/header.html'); require ('/connect_db.php'); $sql = 'SELECT * FROM forum'; $result = mysql_query($dbc, $sql); if ( mysqli_num_rows($result)>0) { echo '<table><tr><th>Posted By</th> <th>Subject</th><th id="msg">Message</th></tr>'; while ($rows=mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr><td>'. $row['first_name'].''. $row['last_name'].'<br>'. $row['post_date'].'</td><td>'. $row['subject'].''. $row['message'].''. } echo'</table>'; else { echo '<p>There are currently no messages.</p>'; } echo'<p><a href="post.php">Post Message</a></p>'; mysqli_close($dbc); incluide('includes/footer.html'); ?> There is no actual footer.html or anything, I doubt that would matter. <?php require ('/connect_db.php'); if (mysqli_ping($dbc)) { echo 'MySQL Server', mysqli_get_server_info($dbc) 'on', mysqli_get_host_info($dbc); } ?> That was correct already.
  15. Html

    Table has error

    Right okay, So this is what it should be, <?php require('\connect_db.php'); $sql='CREATE TABLE IF NOT EXISTS forum('. 'post_id INT UNSIGNED NOT NULL AUTO_INCREMENT,'. 'first_name VARCHAR(20) NOT NULL,'. 'last_name VARCHAR(40) NOT NULL,'. 'first_name VARCHAR(20) NOT NULL,'. 'subject VARCHAR(60) NOT NULL,'. 'message TEXT NOT NULL,'. 'post_date DATETIME NOT NULL,'. 'PRIMARY KEY (post_id))'; if(mysqli_query($dbc, $sql)===True) { echo'Table "forum" created successfully'; } else { echo 'Error Creating table:'.mysqli_error($dbc); } mysqli_close($dbc); ?> The page doesn't do anything when i try to load it, which is obviously how the table would be loaded into the db.
  16. Html

    Table has error

    Okay I tried using func code that created a table. <?php $page_title = 'forum' include('includes/header.html'); require ('\connect_db.php'); $sql = 'SELECT * FROM forum'; $result = mysql_query($dbc, $sql); if ( mysqli_num_rows($result)>0) { echo '<table><tr><th>Posted By</th> <th>Subject</th><th id="msg">Message</th></tr>'; while ($rows=mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<tr><td>'. $row['first_name'].''. $row['last_name'].'<br>'. $row['post_date'].'</td><td>'. $row['subject'].''. $row['message'].''. } echo'</table>'; else { echo '<p>There are currently no messages.</p>'; } echo'<p><a href="post.php">Post Message</a></p>'; mysqli_close($dbc); incluide('includes/footer.html'); ?> So this is forum.php doesn't display anything. <?php require ('/connect_db.php'); if (mysqli_ping($dbc)) { echo 'MySQL Server', mysqli_get_server_info($dbc) 'on', mysqli_get_host_info($dbc); } ?> require.php And create_forum.php <?php require('\connect_db.php'); $sql='CREATE TABLE IF NOT EXISTS forum(' 'post_id INT UNSIGNED NOT NULL AUTO_INCREMENT,'. 'first_name VARCHAR(20) NOT NULL,'. 'last_name VARCHAR(40) NOT NULL,'. 'first_name VARCHAR(20) NOT NULL,'. 'subject VARCHAR(60) NOT NULL,'. 'message TEXT NOT NULL,'. 'post_date DATETIME NOT NULL,'. 'PRIMARY KEY (post_id))'; if(mysqli_query($dbc, $sql)===True) { echo'Table "forum" created successfully'; } else { echo 'Error Creating table:'.mysqli_error($dbc); } mysqli_close($dbc); ?>
  17. Html

    Table has error

    What column? It was Post_id, so either way it doesn't work. The php pages don't display anything, I copied from the book, so not sure what is going on here. The book is from the series by Mike Mcgrath php 7 in easy steps. As for the index.html, what is that about? forum.php should load without the need for a db?
  18. Html

    Table has error

    I created the files, except for the last which is called process.php, the tutorial uses a localhost, so not sure if these files would work fine on any host. The forum.php, nothing does display. It displays an index.html, but there is no step on that, require.php outside of a includes folder along with index.html, and before that htdocs which is on any free host or paid host, and that has connect_db.php includes contains a header.html, and footer, as well css file. I also tried to create the table in the database. So I can't create the table manually or using the page create_forum, nothing loads for that either.
  19. Html

    Table has error

    So that is for a php file then, not to use in the SQL section of the phpmyadmin, that is what you are stating.
  20. Html

    Table has error

    No, but this example in the book won't create a table, unless it means out the sql instructions in the page? I doubt it. I've continued with making the php files, still have to finish step 5 of one, forum.php or create_forum.php
  21. Html

    Table has error

    I have a copy of Php 7 a basic book on creating php files, this is a basic forum page where the following will be sent to a db. I'm just doing what the book has shown. I decided to just try this, as the other book Learning Php doesn't make much sense to me, and I can't get anything done for free what I'm trying to get working, a user login system, post comments and so on. By trying out the chapter in the easy book, I hope to use that as a stepping stone for a user to post comments on their own profile index page. Page 162 creating a forum, so it states require.php <?php require ('/connect_db.php'); if (mysqli_ping($dbc)) { echo 'MySQL Server', mysqli_get_server_info($dbc) 'on', mysqli_get_host_info($dbc); } <?php require ('/connect_db.php'); if (mysqli_ping($dbc)) { echo 'MySQL Server', mysqli_get_server_info($dbc) 'on', mysqli_get_host_info($dbc); } connect_db Then the step two of the forum chapter, assign SQL so then the following in my first post. Then states after now add a test report, whether the table was created successfully or describe the error on failure if(mysqli_query($dbc, $sql)=== TRUE) { echo 'table "forum" created successfully and so on.
  22. Html

    Table has error

    The example has two first_name in the book.
  23. Html

    Table has error

    CREATE DATABASE accounts; CREATE TABLE `accounts`.`users` ( `id` INT NOT NULL AUTO_INCREMENT, `first_name` VARCHAR(50) NOT NULL, `last_name` VARCHAR(50) NOT NULL, `email` VARCHAR(100) NOT NULL, `password` VARCHAR(100) NOT NULL, `hash` VARCHAR(32) NOT NULL, `active` BOOL NOT NULL DEFAULT 0, PRIMARY KEY (`id`) ); This is from an example php files i have, this works, without the db section. Why wouldn't the book example work, I am using a free web host, but that shouldn't matter. I tried this,
  24. Html

    Table has error

    I now get this from your sql table code The example I used was from a book, which is a beginners book for php 7. Thanks.
  25. Html

    Table has error

    Hi, This error is given when I try to create a table for a db. $sql='CREATE TABLE IF NOT EXISTS forum(' 'post_id INT UNSIGNED NOT NULL AUTO_INCREMENT,'. 'first_name VARCHAR(20) NOT NULL,'. 'last_name VARCHAR(40) NOT NULL,'. 'first_name VARCHAR(20) NOT NULL,'. 'subject VARCHAR(60) NOT NULL,'. 'message TEXT NOT NULL,'. 'post_date DATETIME NOT NULL,'. 'PRIMARY KEY (post_id))'; Thanks.
×
×
  • Create New...