Jump to content

Html

Members
  • Posts

    640
  • Joined

  • Last visited

Everything posted by Html

  1. Sure, I understand that. What I want to do is that the code obviously would check and store the email that was removed from posting. That is the purpose in the email table.
  2. No, there it is Forum and email are the two tables. The code states forum. # Name Type Collation Attributes Null Default Extra Action 1 blocked tinyint(1) No None
  3. Well, for now I only want the email, I decided to leave the Ip for the moment, and get this first step done. And yes there is an id so far 1. If you see, I'm trying to picture what needs to go where, <?php $page_title = 'PHP Forum' ; include ( 'includes/header.html' ) ; require ( 'connect_db.php' ) ; $sql = 'SELECT * FROM forum' ; $sql = 'SELECT * FROM email' ; $result = mysqli_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 ( $row = mysqli_fetch_array( $result , MYSQLI_ASSOC )) { echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. $row['post_date'].'</td><td>' . $row['email'] . '</td><td>' . $row['message'] . '</td> </tr>'; } echo '</table>' ; } else { echo '<p>There are currently no messages.</p>' ; } echo '<p><a href="post.php">Post Message</a></p>' ; mysqli_close( $dbc ) ; include ( 'includes/footer.html' ) ; ?> So a blocked column in email. # Name Type Collation Attributes Null Default Extra Action 1 blocked tinyint(1) No None
  4. $sql = "INSERT INTO forum (first_name,last_name,subject,message,post_date) VALUES ('$first_name', '$last_name','$email', '$message', NOW() )" ; Right okay, hang on. So far all there is what there is displayed above. So now a new table will need to be created, so $email as boolean , 0, 1 value? Then the code <?php $page_title = 'PHP Forum' ; include ( 'includes/header.html' ) ; require ( 'connect_db.php' ) ; $sql = 'SELECT * FROM forum' ; $result = mysqli_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 ( $row = mysqli_fetch_array( $result , MYSQLI_ASSOC )) { echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. $row['post_date'].'</td><td>' . $row['email'] . '</td><td>' . $row['message'] . '</td> </tr>'; } echo '</table>' ; } else { echo '<p>There are currently no messages.</p>' ; } echo '<p><a href="post.php">Post Message</a></p>' ; mysqli_close( $dbc ) ; include ( 'includes/footer.html' ) ; ?> This will need to have a verify code once an email is typed in, a comment is displayed which simply states error or posting banned. So the code needs some sort of validation or something, with a connection to the mysql db? There is one there at the top. https://www.w3schools.com/sql/func_mysql_isnull.asp I guess select not from email <?php $page_title = 'PHP Forum' ; include ( 'includes/header.html' ) ; require ( 'connect_db.php' ) ; $sql = 'SELECT * FROM forum' ; $sql = 'SELECT * FROM email' ; $result = mysqli_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 ( $row = mysqli_fetch_array( $result , MYSQLI_ASSOC )) { echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. $row['post_date'].'</td><td>' . $row['email'] . '</td><td>' . $row['message'] . '</td> </tr>'; } echo '</table>' ; } else { echo '<p>There are currently no messages.</p>' ; } echo '<p><a href="post.php">Post Message</a></p>' ; mysqli_close( $dbc ) ; include ( 'includes/footer.html' ) ; ?>
  5. Yes the forum code is from the book Php 7. I don't know what I can do with the code, but yes the project I had with the login failed, so I thought, why not expand on what I would of wanted to do with a comment system for a profile index or something. I would needed something like what I want to do eventually. I think for now, I just want to be able to simply End posting to a email account that is listed,, and that is that. But yes this is the error I have after making those small changes in the code above, enter an email, it won't post.
  6. <?php $page_title = 'PHP Forum' ; include ( 'includes/header.html' ) ; require ( 'connect_db.php' ) ; $sql = 'SELECT * FROM forum' ; $result = mysqli_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 ( $row = mysqli_fetch_array( $result , MYSQLI_ASSOC )) { echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. $row['post_date'].'</td><td>' . $row['email'] . '</td><td>' . $row['message'] . '</td> </tr>'; } echo '</table>' ; } else { echo '<p>There are currently no messages.</p>' ; } echo '<p><a href="post.php">Post Message</a></p>' ; mysqli_close( $dbc ) ; include ( 'includes/footer.html' ) ; ?> Now, I can't post a message, as it states enter a email. <?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[ 'email' ] ) ) ) { $email = addslashes( $_POST[ 'email' ] ) ; } else { fail( 'email' ) ; } 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','$email', '$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') ; } } In the mysql db, email line, boolean and then value? 1, no 0,1 can be stored.
  7. I'm not sure how to do achieve that. I guess the email address form may be the first step to getting a system working. So, email instead of subject, and in the mysql db, change subject to email. Then add boolean to the line of email with true and a false setting.
  8. Alternatively, could use email instead of subject? But the email wouldn't be visible on the posted comments page.
  9. Right, well that is what I'd want to try and do with what I've got here. So I'm going to need what addition to the mysql? $sql = "INSERT INTO forum (first_name,last_name,subject,message,post_date) VALUES ('$first_name', '$last_name','$subject', '$message', 'logged address' NOW() )" ; I won't need an ID, similar to a registration code. So that logged ip, displays on another page, so not sure how that works out with the code above, somehow send data and linked to the new page. And from there, simply button to End posting or block or what ever.
  10. Hi, I wanted to inquire, I have this comment code, forum code is what it is called, from this code example, if I wanted to stop a random poster from posting, could adding some sort of extra code it log the Internet protocol address to stop a spammer for example. I suppose the address would be logged onto another page, where the option to simply stop the poster from submitting a comment. The comment would need an id with which an IP is logged with in the mysql db? <?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[ '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') ; } } process.php And here is the forum.php <?php $page_title = 'PHP Forum' ; include ( 'includes/header.html' ) ; require ( '..\connect_db.php' ) ; $sql = 'SELECT * FROM forum' ; $result = mysqli_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 ( $row = mysqli_fetch_array( $result , MYSQLI_ASSOC )) { echo '<tr><td>' . $row['first_name'] .' '. $row['last_name'] . '<br>'. $row['post_date'].'</td><td>' . $row['subject'] . '</td><td>' . $row['message'] . '</td> </tr>'; } echo '</table>' ; } else { echo '<p>There are currently no messages.</p>' ; } echo '<p><a href="post.php">Post Message</a></p>' ; mysqli_close( $dbc ) ; include ( 'includes/footer.html' ) ; ?> 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', 'logged address' NOW() )" ; $result = mysqli_query( $dbc, $sql ) ; if (mysqli_affected_rows($dbc) != 1) { echo '<p>Error</p>'.mysqli_error($dbc); mysqli_close( $dbc ) ; } This above, some sort of idea on how it would
  11. Html

    WebAuthn

    Hi I read about Webauthn via pcworld weeks ago, and it is a possible new alternative to login security instead of the traditional login. One of these USB keys the PC type standard one is about $45, I had a look at some of the code, Javascript appears to be one of the languages used to get a system setup for a site. Yubico https://developers.yubico.com/FIDO2/FIDO2_WebAuthn_Developer_Guide/Overview.html Not that I can make much sense of it, any thoughts on this code/hardware feature that may be available on sites probably next decade.
  12. Html

    Web Hosting

    Whether they are good or not, shouldn't be the poster's priority, for beginning, a free host is the best option. I know it has serious limits, sub domain has to be used, could be possible to transfer a domain, but usually a paid option. I guess godaddy could be a paid option. I can think of a few UK based paid services, I guess it doesn't too much on where they are based. Easyspace
  13. Html

    Web Hosting

    There are plenty of free hosts via bing search, you can try infinityfree.net, it has certain limits, but for any beginner should be fine. They offer paid hosting too.
  14. Html

    Remove data

    If I am honest, there is a lot there, and good some of it doesn't appeal to me, I'm going directly to what I need, and want. May be a rubbish way of learning this, but that is how I have gone about this. Sure there is a chapter in the In Easy steps book I have php 7. The functions I pasted the code from the source files from the series site, but other than what it expresses, I don't fully understand how it relates to my example. I'm not sure how reading other chapters helps this task alone. I get you're point on learning the basics, I haven't done that, I've taken short cuts. I have had a annoying and tiring time with this, I then decided on example code, since it works, and I was going to take a long time to get anywhere, it hasn't worked out.
  15. Html

    Remove data

    Right... But the code I got from the clips, if it works in them, why doesn't the example work for my system/host environment. You mentioned define, then the php manual, which has some examples of defining, I posted a few on the previous page. I don't quite know where to go with this? function deleteRecord(mysqli $dbc, $user_id){ <?php function deleterecords( $user_id ) { if( $user_id < 0 ) { throw new Exception( "cannot delete" ) ; } } try { user_id( 5 ) ; } catch( Exception $e ) { echo '<b>Size Exception!</b><br>'.$e->getMessage().'<hr>'; } class CustomException extends Exception { public function get_details() { $details = 'File : '.$this->getFile(). '<br>Line : '.$this->getLine(). '<br>'.$this->getMessage(); return $details ; } } Not sure.
  16. I wouldn't know. First time I have used CSS since I first had a book on it back in 2006/2007, and then got rid off in 2008 when I gave up on trying to learn some website design.
  17. Html

    Remove data

    The current code is this, And yes I am still on this, fortunately, I made progress with removing my header image I had on the index page, a couple of others, and replaced it with CSS code🙂 Now that is a first, I had a book years ago on that, I never understood CSS. I am trying to remember what it is called, but I can't think of it. From 2006. So that will save some bandwidth. As for the function code this is still what I have got. The videos show two different ways of doing a function, so I don't know what is wrong or right with what I have.😩 Neither narrators responded to my query with example code. <?php # Connect to the database. require ('connect_db.php'); # Access session. session_start() ; function deleteRecord(mysqli $dbc, $user_id){ $sql ="DELETE FROM 'users' WHERE id ='".$user_id."'"; $result = $db->query($sql); if(!result){ throw new Exception('Cannot delete' ); } } ?> That is remove.php When I click on this from the image link, only a blank screen then loads, so it doesn't work. The logged in user isn't removed from the db instantly, I will want to add a timer to three days after remove.php has been clicked.
  18. Html

    Remove data

    https://youtu.be/W-FkqWUz0eE?t=87 This clip here on removing comments, is similar to what I am trying to do with removing from the db, but what the narrator has displayed, isn't what I have in the code, now the code he uses is php 5 I would imagine, sort of similar to what I have from the book example code, Php & Mysql from the in Easy steps series. The difference between the function I have from another video, and this one, is there is no variable defined, just $sql = if(isset($post['comments])) { $ = $_post That is out of date. At eight minutes
  19. <style> h1 { color: white; } div { border: 2px white; background-color: red; padding-top: 50px; padding-right: 30px; padding-bottom: 50px; padding-left: 80px; } </style> <center> <div><h1>header</h1></div> </center> Now this works.
  20. div { border: 2px white; background-color: red; padding-top: 50px; padding-right: 30px; padding-bottom: 50px; padding-left: 80px; } That is the header in red, that loads, but the text won't load on top in white.
  21. What I want is a coloured header, which is in red, and white text on it, so to replace my header image.
  22. <head> <style> body h1 { color: white; } div { border: 2px white; background-color: red; padding-top: 50px; padding-right: 30px; padding-bottom: 50px; padding-left: 80px; } </style> </head> I have used <h1>header text</h1> in the body section. The padding works, but no text on the padding. Aiming for that https://www.w3schools.com/code/tryit.asp?filename=G1W9NUG2JAYH Thank you.
  23. Html

    Remove data

    For example, the account will be removed in three days from the time it was removed by the user. The code has been changed, but no change in what it should do. 🤨
  24. Html

    Remove data

    Yes, before I change my code, I will want to add a time setting to removing data, and possibly the option to reverse that. I will need to take the next step carefully, where I go with that or how I add to the code, I'm not sure. Once the setting to remove data works, a new page would state the data has been removed. So logging in would bring up a new screen to end the timed setting before removal from the db. I guess for the moment, er, get this code changed, but certainly the next step is a timed removal, with a statement. As it stands just going to remove.php only gives a blank screen, so suspect that would be the result with the change in code. I imagine so. As for message that was from the video tutorial, I did comment on it, but the narrator never responded back.
  25. Html

    Remove data

    Sure I understand the error was on line 13, the cannot delete part. It can only be the word outside of the quote marks. The examples don't show what I have. throw new Exception( message 'Cannot delete' );
×
×
  • Create New...