Jump to content

S A N T A

Members
  • Posts

    68
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

S A N T A's Achievements

Member

Member (2/5)

0

Reputation

  1. I am building a registration page for my blog i am making but for some reason it is not working. It all works and its nice on mozila firefox (Exept my antire website gets all screwed up when i view it in firefox) but in internet explorer i click "Register" and it gives me the 404 error ( Internet Explorer cannot display the webpage ) here is the registration code: <?php session_start(); require("config.php"); $db = mysql_connect($dbhost, $dbuser); mysql_select_db($dbdatabase, $db); if($_POST['submit']) { if($_POST['password'] == $_POST['password2']) { $checksql = "SELECT * FROM user WHERE username = '" . $_POST['username'] . "';"; $checkresult = mysql_query($checksql)or die(mysql_error()); $checknumrows = mysql_num_rows($checkresult); if($checknumrows == 1) { header("Location: " . $config_basedir . "reg.php?error=taken"); } else { echo "Thank you for registering"; for($i = 0; $i < 16; $i++) { $randomstring .= chr(mt_rand(32,126)); } $verifystring = urlencode($randomstring); $validusername = $_POST['username']; $sql = "INSERT INTO user(username, password, name, lastname) VALUES('" . $_POST['username'] . "', '" . $_POST['password'] . "' '" . $_POST['name'] . "' '" . $_POST['lastname'] . "' '" . addslashes($randomstring) . "', 0);"; $query = mysql_query($sql)or die(mysql_error()); require("header.php"); } else(!$query) { header("Location: " . $config_basedir . "reg.php?error=pass"); } else(!empty($_GET['error'])){ require("header.php"); switch($_GET['error']) { case "pass": echo "Passwords do not match!"; break; case "taken": echo "Username taken, please use another."; break; case "no": echo "Incorect login details!"; break; } ?> <h2>Register</h2> To register on <?php echo $config_blogname; ?>, fill out the form below. <form action="<?php echo $SCRIPT_NAME ?>" method="POST"> <table> <tr> <td>Username</td> <td><input type="text" name="username"></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password"></td> </tr> <tr> <td>Re-type Password</td> <td><input type="password" name="password2"></td> </tr> <tr> <td>First Name</td> <td><input type="text" name="name"></td> </tr> <tr> <td>Last Name</td> <td><input type="text" name="lastname"></td> </tr> <tr> <td></td> <td><input type="submit" value="Register!"></td> </tr> </table> </form> <?php } } } echo "CHEEZ"; require("footer.php"); ?> All help appreciated! EDIT: Ok i dont know what i did but now i get this error: Parse error: syntax error, unexpected T_ELSE in "!!MY FILE!!" on line 34
  2. sorry for double post but this is the entire code: <?php session_start(); require("config.php"); ?> <?php if(isset($_GET['id']) == TRUE) { if(is_numeric($_GET['id']) == FALSE) { $error = 1; } if($error == 1) { header("Location: " . $config_basedir); } else { $validentry = $_GET['id']; } } else { $validentry = 0; } if($_POST['delete']) { $db = mysql_connect($dbhost, $dbuser); mysql_select_db($dbdatabase, $db); mysql_query("DELETE FROM comments WHERE id='" . $idofcom . "'"); mysql_query("DELETE FROM comments WHERE blog_id='" . $blogidofcom . "'"); mysql_query("DELETE FROM comments WHERE dateposted='" . $commrow['dateposted'] . "'"); mysql_query("DELETE FROM comments WHERE name='" . $commrow['name'] . "'"); mysql_query("DELETE FROM comments WHERE comment='" . $commrow['comment'] . "'"); } if ( $_POST['submit'] ) { if ( $_POST['comment'] == "" ) { echo "Please write a comment"; } $db = mysql_connect($dbhost, $dbuser); mysql_select_db($dbdatabase, $db); $sql = "INSERT INTO comments(blog_id, dateposted, name, comment) VALUES(" . $validentry . ", NOW(), '" . $_SESSION['USERNAME'] . "', '" . $_POST['comment'] . "');"; mysql_query($sql) or die(mysql_error(). " in $sql"); header('Location: /submited.php'); } else { //code will go here } require("header.php"); if($validentry == 0) { $sql = "SELECT entries.*, categories.cat FROM entries, categories " . "WHERE entries.cat_id = categories.id " . "ORDER BY dateposted DESC " . " LIMIT 1;"; } else { $sql = "SELECT entries.*, categories.cat FROM entries, categories " . "WHERE entries.cat_id = categories.id AND entries.id = " . $validentry . " ORDER BY dateposted DESC LIMIT 1;"; } $result = mysql_query($sql)or die(mysql_error()); $row = mysql_fetch_assoc($result); echo "<h2>" . $row['subject'] . "</h2><br />"; echo "<i>In <a href='viewcat.php?id=" . $row['cat_id'] ."'>" . $row ['cat'] ."</a> - Posted on " . date("D jS FY g.iA", strtotime($row['dateposted'])) ."</i>"; if(isset($_SESSION['ADMIN']) == TRUE) { echo" [<a href='updateentry.php?id=" . $row['id'] . "'>edit</a>]"; } echo "<p>"; echo nl2br($row['body']); echo "</p>"; $commsql = "SELECT * FROM comments WHERE blog_id = " . $validentry . " ORDER BY dateposted DESC;"; $commresult = mysql_query($commsql); $numrows_comm = mysql_num_rows($commresult); if(isset($_SESSION['USERNAME']) == TRUE) { if($numrows_comm == 0) { echo "<p>No comments.</p>"; } else { $i = 1; while($commrow = mysql_fetch_assoc($commresult)) { echo "<a name='comment" . $i . "'>"; echo "<h3>Comment by " . $commrow['name'] . " on " . date("D jS F Y g.iA", strtotime($commrow['dateposted'])) . "</h3>"; if(isset($_SESSION['ADMIN']) == TRUE) { $idofcom = $commrow['id']; $blogidofcom = $commrow['blog_id']; ?> <form action="<?php echo $SCRIPT_NAME . "?id=" . $validentry; ?>" method="post"> <input type="submit" name="delete" value="Delete"> </form> <?php echo $idofcom; ?><br /> <?php echo $blogidofcom; ?><br /> <?php echo $commrow['dateposted']; ?><br /> <?php echo $commrow['name']; ?><br /> <?php echo $commrow['comment']; ?><br /> <?php } echo $commrow['comment']; $i++; } } ?> <form action="<?php echo $SCRIPT_NAME . "?id=" . $validentry; ?>" method="post"> <table> <tr> <td> <h3>Leave a comment</h3> </td> </tr> <tr> <td>Comments</td> <td><textarea name="comment" rows="10" cols="50"></textarea></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="Add Comment"></td> </tr> <tr> <td> <font size="-2">Do not post inapropriate comments or they will be deleted</font> </td> </tr> </form> </table> <?php } else { echo "Login to view/add comments!"; } require("footer.php"); ?>
  3. ok so i am trying to allow a button to be pushed that deletes an input from the database here is the code: if($_POST['delete']) { $db = mysql_connect($dbhost, $dbuser); mysql_select_db($dbdatabase, $db); mysql_query("DELETE FROM comments WHERE id='" . $idofcom . "'"); mysql_query("DELETE FROM comments WHERE blog_id='" . $blogidofcom . "'"); mysql_query("DELETE FROM comments WHERE dateposted='" . $commrow['dateposted'] . "'"); mysql_query("DELETE FROM comments WHERE name='" . $commrow['name'] . "'"); mysql_query("DELETE FROM comments WHERE comment='" . $commrow['comment'] . "'"); } but it doesn't work here is my delete button: if(isset($_SESSION['ADMIN']) == TRUE) { $idofcom = $commrow['id']; $blogidofcom = $commrow['blog_id']; ?> <form action="<?php echo $SCRIPT_NAME . "?id=" . $validentry; ?>" method="post"> <input type="submit" name="delete" value="Delete"> </form> <?php } Thanks in advance
  4. how would i do that and how would i make it delete the selected one?
  5. sorry i don't get it? I'm very new to PHP.
  6. ok so i have a blog and it allows users to post comments when they are logged in BUT if i don't like a comment that was posted or its just spam i would like to be able to delete it. here is the code i tried: if($_POST['delete']) { $db = mysql_connect($dbhost, $dbuser); mysql_select_db($dbdatabase, $db); $sql = "DELETE FROM 'comments' WHERE 'comments'.'id' = " . "" } that is where i got stuck and i had no idea how to make it specifically delete that comment and not another one. Thanks so much for helping in advance! the entire code is: <?php session_start(); require("config.php"); ?> <?php if(isset($_GET['id']) == TRUE) { if(is_numeric($_GET['id']) == FALSE) { $error = 1; } if($error == 1) { header("Location: " . $config_basedir); } else { $validentry = $_GET['id']; } } else { $validentry = 0; } if($_POST['delete']) { $db = mysql_connect($dbhost, $dbuser); mysql_select_db($dbdatabase, $db); #$sql = "DELETE FROM 'comments' WHERE 'comments'.'id' = " . "" } if ( $_POST['submit'] ) { if ( $_POST['comment'] == "" ) { echo "Please right a comment"; } $db = mysql_connect($dbhost, $dbuser); mysql_select_db($dbdatabase, $db); $sql = "INSERT INTO comments(blog_id, dateposted, name, comment) VALUES(" . $validentry . ", NOW(), '" . $_SESSION['USERNAME'] . "', '" . $_POST['comment'] . "');"; mysql_query($sql) or die(mysql_error(). " in $sql"); header('Location: /submited.php'); } else { //code will go here } require("header.php"); if($validentry == 0) { $sql = "SELECT entries.*, categories.cat FROM entries, categories " . "WHERE entries.cat_id = categories.id " . "ORDER BY dateposted DESC " . " LIMIT 1;"; } else { $sql = "SELECT entries.*, categories.cat FROM entries, categories " . "WHERE entries.cat_id = categories.id AND entries.id = " . $validentry . " ORDER BY dateposted DESC LIMIT 1;"; } $result = mysql_query($sql)or die(mysql_error()); $row = mysql_fetch_assoc($result); echo "<h2>" . $row['subject'] . "</h2><br />"; echo "<i>In <a href='viewcat.php?id=" . $row['cat_id'] ."'>" . $row ['cat'] ."</a> - Posted on " . date("D jS FY g.iA", strtotime($row['dateposted'])) ."</i>"; if(isset($_SESSION['ADMIN']) == TRUE) { echo" [<a href='updateentry.php?id=" . $row['id'] . "'>edit</a>]"; } echo "<p>"; echo nl2br($row['body']); echo "</p>"; $commsql = "SELECT * FROM comments WHERE blog_id = " . $validentry . " ORDER BY dateposted DESC;"; $commresult = mysql_query($commsql); $numrows_comm = mysql_num_rows($commresult); if(isset($_SESSION['USERNAME']) == TRUE) { if($numrows_comm == 0) { echo "<p>No comments.</p>"; } else { $i = 1; while($commrow = mysql_fetch_assoc($commresult)) { echo "<a name='comment" . $i . "'>"; echo "<h3>Comment by " . $commrow['name'] . " on " . date("D jS F Y g.iA", strtotime($commrow['dateposted'])) . "</h3>"; if(isset($_SESSION['ADMIN']) == TRUE) { echo"[<a name='delete' href='viewentry.php?id=" . $row['id'] . "'>delete</a>]"; } echo $commrow['comment']; $i++; } } ?> <table> <tr> <td> <h3>Leave a comment</h3> </td> </tr> <form action="<?php echo $SCRIPT_NAME . "?id=" . $validentry; ?>" method="post"> <tr> <td>Comments</td> <td><textarea name="comment" rows="10" cols="50"></textarea></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="Add Comment"></td> </tr> <tr> <td> <font size="-2">Do not post inapropriate comments or they will be deleted</font> </td> </tr> </form> </table> <?php } else { echo "Login to view/add comments!"; } require("footer.php"); ?>
  7. that sort of worked but it still allowed someone to submit a comment it just echoed "Please right a comment"
  8. also i want to restrict HTML and having nothing in the comments box so i tried this code: if($_POST['submit']) { if($_POST['comment']) == "" { echo "Please right a comment" } but it did not work
  9. yes thats what i would like it to do
  10. EDIT: ok i got it to work now i have another problem when you push the submit button it refreshes the page and the page is all messed up
  11. i don't see where the error is sorry I'm very new to PHP
  12. i am building a blog and everything is working fine but there is one problem with this code: <?php session_start(); require("config.php"); ?> <?php if(isset($_GET['id']) == TRUE) { if(is_numeric($_GET['id']) == FALSE) { $error = 1; } if($error == 1) { header("Location: " . $config_basedir); } else { $validentry = $_GET['id']; } } else { $validentry = 0; } if($_POST['submit']) { $db = mysql_connect($dbhost, $dbuser); mysql_select_db($dbdatabase, $db); $sql = "INSERT INTO comments(blog_id, dateposted, name, comment) VALUES(" . $validentry . ", NOW(), '" . $_SESSION['USERNAME'] . "', '" . $_POST['comment'] . "');"; mysql_query($sql) or die(mysql_error(). " in $sql"); header("Location: " . $config_basedir); } else { //code will go here } require("header.php"); if($validentry == 0) { $sql = "SELECT entries.*, categories.cat FROM entries, categories " . "WHERE entries.cat_id = categories.id " . "ORDER BY dateposted DESC " . " LIMIT 1;"; } else { $sql = "SELECT entries.*, categories.cat FROM entries, categories " . "WHERE entries.cat_id = categories.id AND entries.id = " . $validentry . " ORDER BY dateposted DESC LIMIT 1;"; } $result = mysql_query($sql)or die(mysql_error()); $row = mysql_fetch_assoc($result); echo "<h2>" . $row['subject'] . "</h2><br />"; echo "<i>In <a href='viewcat.php?id=" . $row['cat_id'] ."'>" . $row ['cat'] ."</a> - Posted on " . date("D jS FY g.iA", strtotime($row['dateposted'])) ."</i>"; if(isset($_SESSION['ADMIN']) == TRUE) { echo" [<a href='updateentry.php?id=" . $row['id'] . "'>edit</a>]"; } echo "<p>"; echo nl2br($row['body']); echo "</p>"; $commsql = "SELECT * FROM comments WHERE blog_id = " . $validentry . " ORDER BY dateposted DESC;"; $commresult = mysql_query($commsql); $numrows_comm = mysql_num_rows($commresult); if(isset($_SESSION['USERNAME']) == TRUE) { if($numrows_comm == 0) { echo "<p>No comments.</p>"; } else { $i = 1; while($commrow = mysql_fetch_assoc($commresult)) { echo "<a name='comment" . $i . "'>"; echo "<h3>Comment by " . $commrow['name'] . " on " . date("D jS F Y g.iA", strtotime($commrow['dateposted'])) . "</h3>"; echo $commrow['comment']; $i++; } ?> <table> <tr> <td> <h3>Leave a comment</h3> </td> </tr> <form action="<?php echo $SCRIPT_NAME . "?id=" . $validentry; ?>" method="post"> <tr> <td>Comments</td> <td><textarea name="comment" rows="10" cols="50"></textarea></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="Add Comment"></td> </tr> <tr> <td> <font size="-2">Do not post inapropriate comments or they will be deleted</font> </td> </tr> </form> </table> <?php } } else { echo "Login to view/add comments!"; } require("footer.php"); ?> the problem is is that footer.php is not being displayed (it has my copyright stuff on it) and that the form is not being displayed. is there something wrong with my .css file? body { font-family: "trbuchet ms", verdena, sans-serif; font-size: 24px; line-hight: 1.5em; color: #000000; background: #3399FF; margin: 0; padding: 0; text-align: center; width: 100% } #header { position: absolute; top: 0px; left: 0px; hight: 60px; width: 100%; background: #3898B8; padding-top: 8px; } #menu { font-family: "trebuchet ms", verdana, sans-serif; font-size: 14px; font-weight: bold; position: absolute; height: 27px; top: 60px; left: 0px; width: 100%; padding: 0px; color: #000000; background-color: #3399FF; } a:link { text-decoration: none; color: #000 } a:visited { text-decoration: none; border-bottom: 1px dotted #369; color: #000; } a:hover, a:active { text-decoration: none; border-bottom: 1px solid #036; color: #000 } #container { position: absolute; top: 85px; left: 0px; background: #3399FF; margin: 0 auto 0 auto; text-align: left; width: 100%; height: 100% } #bar { float: left; width: 200px; background: #95C78D; padding: 10px; margin-right: 30px; height: 94%; } img { border: 0; } #bar h1 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.3em; } #main { margin: 15px 15px 15px 240px; padding: 15px 15px 15px 15px; background: #76ABED; text-align: left; } i get no errors whatsoever and everything else is working perfectly Thanks in advance!
  13. ok nvm i fixed it and i got it to work
  14. ok so i am trying to display all the users and heir emails that have registered on my site BUT i cant seem to get them in a table the table needs to be border 1 but i cant get it for some reason <?php $sql = "SELECT * FROM `users`"; $result = mysql_query($sql)or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { echo "<table border="1"><tr><td> " . $row['username'] . " </td><td> "; <----- that is line 21 echo " " . $row['email'] . "</td></tr><br /><br />"; } ?> but i get the error Parse error: parse error, unexpected T_LNUMBER, expecting ',' or ';' in userdisplay.php on line 21
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.