Jump to content

Html

Members
  • Posts

    640
  • Joined

  • Last visited

Everything posted by Html

  1. I only have one of the books, and there is no chapter on sending email from a form or message to an address.
  2. Right well the example above is fine, I just want to get that to actually send off a message to an email address.
  3. I thought that was the purpose of that example in the book. Can it be modified to do that then? I guess it can, what do I need to do?
  4. The book is correct, when I did this yesterday, I left out the "" for text alone, who knows why I typed it that way. text name wasn't correct. With that example, just how does a message get sent to an email of a web page administrator?
  5. I copied it exactly as the chapter states. Is identical to what is there.
  6. Hi, I have tried an example from Php 7 in easy steps book. I don't understand how this code is suppose to work, it didn't quite work for me as demonstrated in the chapter of this book. <form action="action_handler.php" method="POST"> <dl> <dt>Name: <dd><input type="text name="name"> <dt>Email Address: <dd><input type="text name="mail"> <dt>Your Message: <dd><textarea rows="10" cols="20" name="comment"> </textarea> </dl> <p><input type="submit" value="Submit"></p> </form> That was the result after it goes to action_handler.php So below is the code, it is an odd example, I assumed it would contain some kind of send off to an address. <!DOCTYPE HTML> <html lang="en"> <head> <meta charset="UTF-8"> <title>PHP Form Handler</title> </head> <body> <?php $name = $_POST['name'] ; $mail = $_POST['mail'] ; $comment = $_POST['comment'] ; echo "<p>Thanks for this comment $name ...</p>" ; echo "<p><i>$comment</i></p>" ; echo "<p>We will reply to $mail</p>" ; ?> </body> </html> Thank you.
  7. I wouldn't be concerned about it. This is an education forum. There are numerous forums out there that don't have have an encryption. This site doesn't make any money, so it is funded through some ads.
  8. Html

    user id

    Yes a user will post a comment to forum table, and the session id will retrieve that user's comment and display it on the index, so just like the name is stored in the users table.
  9. Html

    user id

    Well I actually took a look at the comment files, and I can post to the table without having needed to be logged in, so like the profile name, it would need to have some kind of code that identifies a user with a control panel page, so when posting a comment it works for that index page of the registered user. Having thought about it what with little I know and have, I can't see how it could be done, other than having numerous tables for a new user's name. Obviously I'm getting ahead of what I have been trying to do, but I just thought I'd think into it a little to see how it could be done.
  10. Definitely needs changing.
  11. Html

    user id

    I guess this will be a similar process for a comment posting to the db, which I have from the example file of the book I have on creating a forum. Similar process to display a comment on a session user id page
  12. Html

    user id

    <?php ini_set('display_errors', 1); error_reporting(E_ALL); # Access session. session_start() ; $user_id = $_SESSION['user_id']; # Redirect if not logged in. if ( !isset( $_SESSION[ 'user_id' ] ) ) { require ( 'login_tools.php' ) ; load() ; } if (isset( $user_id )) { echo '<div>We have a green light that $user_id is set and has a value <div style="width:1em; height: 1em; display: inline-block; background: lime;"></div> and equals: ' . $user_id . '</div>'; } else { echo 'We have a red light that $user_id is set, but has NO VALUE <div style="width:1em; height: 1em; display: inline-block; background: red;"> and equals: ' . $user_id . ' </div>'; } # On success retrieve user_id, first_name, and last name from 'users' database. if ( empty( $errors ) ) { $user_id = "SELECT user_id, first_name, last_name FROM users WHERE user_id='$user_id'" ; $r = mysqli_query ( $user_id, $q ) ; if ( @mysqli_num_rows( $r ) == 1 ) $row = mysqli_fetch_array ( $r, MYSQLI_ASSOC ) ; echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. '</td> </tr>'; echo '</table>' ; } $r = mysqli_query ( $user_id ); ?>
  13. Html

    user id

    Web connection is back, it was down for the weekend. Right okay, I read what you stated in the post, <?php ini_set('display_errors', 1); error_reporting(E_ALL); # Access session. session_start() ; $user_id = $_SESSION['user_id']; if (isset( $user_id )) { echo '<div>We have a green light that $user_id is set and has a value <div style="width:1em; height: 1em; display: inline-block; background: lime;"></div> and equals: ' . $user_id . '</div>'; } else { echo 'We have a red light that $user_id is set, but has NO VALUE <div style="width:1em; height: 1em; display: inline-block; background: red;"> and equals: ' . $user_id . ' </div>'; } # Redirect if not logged in. if ( !isset( $_SESSION[ 'user_id' ] ) ) { require ( 'login_tools.php' ) ; load() ; } # On success retrieve user_id, first_name, and last name from 'users' database. if ( empty( $errors ) ) { $user_id = "SELECT user_id, first_name, last_name FROM users WHERE user_id='$user_id'" ; $r = mysqli_query ( $user_id, $q ) ; if ( @mysqli_num_rows( $r ) == 1 ) $row = mysqli_fetch_array ( $r, MYSQLI_ASSOC ) ; echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. '</td> </tr>'; echo '</table>' ; } $r = mysqli_query ($dbc, $q); ?> Why does 29 display, something wrong with row?
  14. Html

    user id

    Notice: Undefined variable: q on line 22 mysqli_query() expects parameter 1 to be mysqli, string given on line 22 Undefined variable: row on line 29 Undefined variable: dbc on line 36 Undefined variable: q on line 36 mysqli_query() expects parameter 1 to be mysqli, null give on line 36 <?php ini_set('display_errors', 1); error_reporting(E_ALL); # Access session. session_start() ; # Redirect if not logged in. if ( !isset( $_SESSION[ 'user_id' ] ) ) { require ( 'login_tools.php' ) ; load() ; } $user_id = $_SESSION['user_id']; if (isset( $user_id )) { echo '<div>We have a green light that $user_id is set and has a value <div style="width:1em; height: 1em; display: inline-block; background: lime;"></div> and equals: ' . $user_id . '</div>'; } else { echo 'We have a red light that $user_id is set, but has NO VALUE <div style="width:1em; height: 1em; display: inline-block; background: red;"> and equals: ' . $user_id . ' </div>'; } # On success retrieve user_id, first_name, and last name from 'users' database. if ( empty( $errors ) ) { $user_id = "SELECT user_id, first_name, last_name FROM users WHERE user_id='$user_id'" ; $r = mysqli_query ( $user_id, $q ) ; if ( @mysqli_num_rows( $r ) == 1 ) $row = mysqli_fetch_array ( $r, MYSQLI_ASSOC ) ; echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. '</td> </tr>'; echo '</table>' ; } $r = mysqli_query($dbc, $q); ?>
  15. Html

    user id

    I was trying to edit the file on the free host, but got logged out, couldn't connect to line on socket.
  16. Html

    user id

    Notice: Undefined variable: user_id on line 13 Warning: mysqli_query() expects at least 2 parameters, 1 given on 14 Notice: Undefined variable: row on line 21 If I remove the comma, the error messages appear ( $user_id, ) And whether user_id or first name doesn't make any difference. I changed it back to first name.
  17. Html

    user id

    $row['user_id'] .' '. The errors before tinkering with it were, lines 21, and 13, and 14. $r = mysqli_query ( $user_id, ) ; Once I changed them, the blank page was displayed. From the column in the db? email is just that email, user_id is exactly that as the image in the top post displays. Unless you are getting at the fact that there is no underscore in the actual column name?
  18. Html

    user id

    I managed to try out the file, web host is back up since last week, so yes, I tried out, and a bunch of errors, I tried tickering with it, and got this result, but yes it doesn't do what it should. <?php ini_set('display_errors', 1); error_reporting(E_ALL); # Access session. session_start() ; # Redirect if not logged in. if ( !isset( $_SESSION[ 'user_id' ] ) ) { require ( 'login_tools.php' ) ; load() ; } # On success retrieve user_id, first_name, and last name from 'users' database. if ( empty( $errors ) ) { $user_id = "SELECT user_id, first_name, last_name FROM users WHERE email='$user_id'" ; $r = mysqli_query ( $user_id, ) ; if ( @mysqli_num_rows( $r ) == 1 ) $row = mysqli_fetch_array ( $r, MYSQLI_ASSOC ) ; echo '<tr><td>' . $row['user_id'] .' '. $row['last_name'] . '<br>'. '</td> </tr>'; echo '</table>' ; } ?>
  19. Html

    user id

    Okay, I will respond as soon as the free host is up again, there appears to be downtime. At least I have got this corrected, partially. Thanks
  20. Html

    user id

    <?php ini_set('display_errors', 1); error_reporting(E_ALL); # Access session. session_start() ; # Redirect if not logged in. if ( !isset( $_SESSION[ 'user_id' ] ) ) { require ( 'login_tools.php' ) ; load() ; } # On success retrieve user_id, first_name, and last name from 'users' database. if ( empty( $errors ) ) { $q = "SELECT user_id, first_name, last_name FROM users WHERE email='$user_id'" ; $r = mysqli_query ( $dbc, $q ) ; if ( @mysqli_num_rows( $r ) == 1 ) $row = mysqli_fetch_array ( $r, MYSQLI_ASSOC ) ; echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. '</td> </tr>'; echo '</table>' ; } mysqli_close($dbc); ?> Okay the official php checker has given an okay with this.
  21. Html

    user id

    Sure, I don't know the syntax and spacing of the code, as I found out when I typed out the forum tutorial page for page, and then you got me the files. So I got somewhere with that. Okay, the code to get this to work is missing, and incorrect. Then this isn't quite as simple as I thought, you stated you left certain clues about the select query part. <?php ini_set('display_errors', 1); error_reporting(E_ALL); # Access session. session_start() ; # Redirect if not logged in. if ( !isset( $_SESSION[ 'user_id' ] ) ) { require ( 'login_tools.php' ) ; load() ; } # On success retrieve user_id, first_name, and last name from 'users' database. if ( empty( $errors ) ) { $q = "SELECT user_id, first_name, last_name FROM users WHERE email='$user_id'" ; $r = mysqli_query ( $dbc, $q ) ; if ( @mysqli_num_rows( $r ) == 1 ) { $row = mysqli_fetch_array ( $r, MYSQLI_ASSOC ) ; { echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. '</td> </tr>'; echo '</table>' ; } mysqli_close($dbc); ?> Not sure if that edit works.
  22. Html

    user id

    <?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'); ?> According to the forum code, there is one of those curly braces just under echo. if ( empty( $errors ) ) { $q = "SELECT user_id, first_name, last_name FROM users WHERE email='$user_id'" ; $r = mysqli_query ( $dbc, $q ) ; if ( @mysqli_num_rows( $r ) == 1 ) { $row = mysqli_fetch_array ( $r, MYSQLI_ASSOC ) ; { echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. '</td> </tr>'; } { echo '</table>' ; } ?> So this bottom part of profile was missing one of those, from your hint.
  23. Html

    user id

    The only part I focused on was the comment box, or forum, which I simply just downloaded the files from the site, since I tried typing it all out, and it was a waste of time since it didn't work. So I took that short cut. I then viewed the other files, and noticed I could use that login system as they were from a book called Php and mysql. So yes, looked at the code, and took the forum part about inserting data, and used the user id part from the login and put them together, as displayed. And you've given me some pointers, which I'm struggling with. The php 7 basic book is just that, it doesn't really go into explanations word for word. As for the Learning php book, no good really for me. That was why I preferred a video. Forget about that. line 23 is an error according to that check system. I tried this, and now 30 is the problem. <?php ini_set('display_errors', 1); error_reporting(E_ALL); # Access session. session_start() ; # Redirect if not logged in. if ( !isset( $_SESSION[ 'user_id' ] ) ) { require ( 'login_tools.php' ) ; load() ; } # On success retrieve user_id, first_name, and last name from 'users' database. if ( empty( $errors ) ) { $q = "SELECT user_id, first_name, last_name FROM users WHERE email='$user_id'" ; $r = mysqli_query ( $dbc, $q ) ; if ( @mysqli_num_rows( $r ) == 1 ) { $row = mysqli_fetch_array ( $r, MYSQLI_ASSOC ) ; { echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. '</td> </tr>'; } echo '</table>' ; } ?>
  24. Html

    user id

    <?php ini_set('display_errors', 1); error_reporting(E_ALL); # Access session. session_start() ; # Redirect if not logged in. if ( !isset( $_SESSION[ 'user_id' ] ) ) { require ( 'login_tools.php' ) ; load() ; } # On success retrieve user_id, first_name, and last name from 'users' database. if ( empty( $errors ) ) { $q = "SELECT user_id, first_name, last_name FROM users WHERE email='$user_id'" ; $r = mysqli_query ( $dbc, $q ) ; if ( @mysqli_num_rows( $r ) == 1 ) { $row = mysqli_fetch_array ( $r, MYSQLI_ASSOC ) ; { echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. </td><td>' . </td> </tr>'; } echo '</table>' ; } ?> I'm not sure about that, bare in mind I only have the php 7 book which has a chapter on variables, never read that part, from what I can gather it mentions user, but nothing about a $user, you state it doesn't matter that much. In the defining constants page, 'USER', 'Mike'); echo 'Hello' . USER ; Hello how is your puppy is the statement example. You hare using php 7.0.4
  25. Html

    user id

    I don't quite know what to state to where does the $user_id originates from, in the db it is simply user_id, so neither that or $id work in the profile code. 1 or 2 is from the db as the example image I've uploaded displays, so the code above has to read one of those numbers of the user logged in. It is that easy I'm sure, but I can't see it.
×
×
  • Create New...