Jump to content

ckerr27

Members
  • Posts

    54
  • Joined

  • Last visited

    Never

Everything posted by ckerr27

  1. Thanks Danny!!Although this is what the page displayed: 1scott1Error: Unknown column '1scott1' in 'where clause' 1scott1 is the username of the logged in member
  2. Yes mate, Sorry I had already realised that updated it, $sql="UPDATE $tbl_name SET firstname='{$_POST['firstname']}', surname='{$_POST['surname']}', dob='{$_POST['dob']}', totalwins='{$_POST['wins']}', totalloses='{$_POST['loses']}', email='{$_POST['email']}', country='{$_POST['born']}', info='{$_POST['other']}' WHERE username='$_SESSION['myusername']'"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } else { echo "Details Updated"; } ?> Still cannot find what is missing :'( By the way, I am not after people to debug this I am simply looking help as I am new to PHP and have been trying to get this for days. Thanks everyone who is trying to help
  3. I tried this code which is similar to code i used elsewhere but it is still giving me a error on the $sql=mysql_query line: <?php session_start(); echo $_SESSION['myusername']; mysql_connect ("localhost","root","") or die("Cannot connect to Database"); mysql_select_db ("test"); $sql = "UPDATE memberdetails WHERE username=$_SESSION['myusername']"; $result = mysql_query ($sql); while ($row = mysql_fetch_array($result)) { $firstname= $row["firstname"]; $surname= $row["surname"]; $dob= $row["dob"]; $wins= $row["totalwins"]; $loses= $row["totalloses"]; $email= $row["email"]; $born= $row["country"]; $other= $row["info"]; echo "<b><u>Firstname:</b></u> $firstname<br>"; echo "<b><u>Surname: </b> </u> $surname<br>"; echo "<b><u>Date of Birth:</b></u> $dob<br>"; echo "<b><u>Total Chess Wins:</b></u> $wins<br>"; echo "<b><u>Total Chess loses:</b></u> $loses<br>"; echo "<b><u>Email Address: </b></u> $email<br>"; echo "<b><u>Born in: </b></u> $born<br>"; echo "<b><u>Other Details:</b></u> $other<br><br><br>"; } ?> I am not sure if am on the correct track or not here?Sorry I am new to PHP
  4. $sql=mysql_query("UPDATE memberdetails SET firstname='{$_POST['firstname']}', surname='{$_POST['surname']}', dob='{$_POST['dob']}', totalwins='{$_POST['wins']}', totalloses='{$_POST['loses']}', email='{$_POST['email']}', country='{$_POST['born']}', info='{$_POST['other']} WHERE username=$_SESSION['myusername']"); Thanks but it is still giving me the same error. Sorry i am not sure how to use php tags
  5. Hi everyone, I have been trying to get this code working but no matter what I try it will not work, I am trying to allow a user to update their personal details when they login to my website. I have created a form and submit button, the code is shwn below: <?php echo $_SESSION['myusername']; ?> <br><br> <form action="updated.php" method="post"> Firstname: <input type="text" name="firstname" /><br><br> Surname : <input type="text" name="surname" /><br><br> Date Birth: <input type="text" name="dob" /><br><br> Total Wins: <input type="text" name="wins" /> Total Loses: <input type="text" name="loses" /><br><br> Email Add: <input type="text" name="email" /><br><br> Country : <input type="text" name="born" /><br><br> Other Info: <input type="text" name="other" /><br><br> <input type="submit" name="Submit" value="Update" align="right"></td> </form> The updated.php file <?php mysql_connect ("localhost","root","") or die("Cannot connect to Database"); mysql_select_db ("test"); $sql=mysql_query("UPDATE memberdetails SET firstname='{$_POST['firstname']}', surname='{$_POST['surname']}', dob='{$_POST['dob']}', totalwins='{$_POST['wins']}', totalloses='{$_POST['loses']}', email='{$_POST['email']}', country='{$_POST['born']}', info='{$_POST['other']} WHERE username=$_SESSION['myusername']); if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "Details Updated"; ?> This is the error i recieve: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\website\updated.php on line 45 Line 45 is $sql=mysql_query line If anybody can help it will be very much appreciated!
  6. I hop i have used the correct code tags! This is the complete file: #<html> #<head> #<link rel="stylesheet" type ="text/css" href="anything2.css" #</head> #<body> #<div id="container"> #<div id="header"><img src="imagesb.jpg" alt="Cool Image" align="left"> #<img src="images.jpg" alt="Cool Image" align="right"><center><b><font size="6.5"><br><br>Future Events</b></center></font> #</div> #<div id="leftnav"><center> #<br><br> #<input type= "button" style="width:120px;" value="Home" onClick="window.location= 'adminhome.php' "> #<br><br> #<input type= "button" style="width:120px;" value="Personal Details" onClick="window.location= 'adpersonaldetails.php' "> #<br><br> #<input type= "button" style="width:120px;" value="Club Details" onClick="window.location= 'adclubdetails.php' "> #<br><br> #<input type= "button" style="width:120px;" value="News" onClick="window.location= 'adnews.php' "> #<br><br> #<input type= "button" style="width:120px;" value="FAQ" onClick="window.location= 'adfaq.php' "> #<br><br> #<input type= "button" style="width:120px;" value="Wall" onClick="window.location= 'adwall.php' "> #<br><br> #<input type= "button" style="width:120px;" value="About Us" onClick="window.location= 'adabout.php' "> #</div> #<div id="body"> #<?php #$host="localhost"; // Host name #$username="root"; // Mysql username #$password=""; // Mysql password #$db_name="test"; // Database name #$tbl_name="event"; // Table name #mysql_connect("$host", "$username", "$password")or die("cannot connect"); #mysql_select_db("$db_name")or die("cannot select DB"); #$result = my_sql_query("SELECT * FROM event WHERE eventid = '1'"); #while($row = mysql_fetch_array($result)) { # $eventname= $row["eventname"]; # $eventdate= $row["eventdate"]; # # echo "<b><u>Event Name:</b></u> $eventname"; # echo "<b><u>Event Date:</b></u> $eventdate<br>"; # } #?> #<div id="footer">This is the footer</div> #</body> #</html>
  7. Thanks but sorry its still not working, the code looks correct to me I cannot work out why it is not displaying the info, the database and table names are all correct.
  8. Hi I am trying to display data from the table "event" in my database, I use the code below but it will not work and I cannot figure out why. CAn anyone help? CODE: <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="test"; // Database name $tbl_name="event"; // Table name mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $result = my_sql_query("SELECT * FROM event WHERE eventid = '1'"); while($row = mysql_fetch_array($result)) { $eventname= $row["eventname"]; $eventdate= $row["eventdate"]; echo "<b><u>Event Name:</b></u> $eventname" echo "<b><u>Event Date:</b></u> $eventdate<br>"; } ?> DISPLAY: Event Name: $eventname echo "Event Date: $eventdate "; } ?>
  9. Do you mean something like this?I have attached the error i am getting from this code: $sql="UPDATE memberdetails SET firstname='{$_POST['firstname']}', surname='{$_POST['surname']}', dob='{$_POST['dob']}', totalwins='{$_POST['wins']}', totalloses='{$_POST['loses']}', email='{$_POST['email']}', country='{$_POST['born']}', info='{$_POST['other']} WHERE username=$_SESSION['myusername'];}
  10. Thanks I understand, I only have the password stored in the members table, the other table is attached. I am trying to use code to allow the logged in member to update their personal details (only their own) I have started with this code: form: <?php echo $_SESSION['myusername']; ?> <br><br> <form action="updated.php" method="post"> Firstname: <input type="text" name="firstname" /><br><br> Surname : <input type="text" name="surname" /><br><br> Date Birth: <input type="text" name="dob" /><br><br> Total Wins: <input type="text" name="wins" /> Total Loses: <input type="text" name="loses" /><br><br> Email Add: <input type="text" name="email" /><br><br> Country : <input type="text" name="born" /><br><br> Other Info: <input type="text" name="other" /><br><br> <input type="submit" name="Submit" value="Update" align="right"></td> </form> updated.php <div id="body"> <?php echo $_SESSION['myusername']; ?> <br><br> <?php mysql_connect ("localhost","root","") or die("Cannot connect to Database"); mysql_select_db ("test"); $sql="UPDATE memberdetails WHERE username=['myusername'] (firstname, surname, dob, totalwins, totalloses, email, country, info) VALUES( '{$_POST['firstname']}','{$_POST['surname']}','{$_POST['dob']}','{$_POST['wins']}','{$_POST['loses']}','{$_POST['email']}','{$_POST['born']}','{$_POST['other']}' )"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "Details Updated"; ?> I know this is similar to the previous code, Its the WHERE that i cannot get to work, should the WHERE be placed into the code to ensure the record being updated belongs to which ever user is logged in?
  11. Yes that was it thanks. I have attacthed an image of my members table, it is for logging in and the other is simply information about the user, the code above was adding the information about the new user to the memberdetails table. is there anyway i can add the username of the new member to the members table and generate a password to allow them to login?
  12. Thanks Muddy_funster it added the new member to the table. I am getting an error which i have attached an image of. Also, the new user has his/her username. I have another table in the database containing username and passwords for each member, the passwords are MD5 (phpmyadmin) is there anyway the user can be given a login password with their username when the new member is added? Thanks a million!
  13. Hello everyone, I am trying to have a function on my website where the administrator can add a new member to the database. Their details are to be stored in the table memberdetails, I have posted the code below, the error i recieve is "Error: Column count doesn't match value count at row 1" Can anybody help me please? form code: <form action="insert.php" method="post"> Username: <input type="text" name="username" /><br><br> Firstname: <input type="text" name="firstname" /><br><br> Surname : <input type="text" name="surname" /><br><br> Date Birth: <input type="text" name="dob" /><br><br> Total Wins: <input type="text" name="wins" /> Total Loses: <input type="text" name="loses" /><br><br> Email Add: <input type="text" name="email" /><br><br> Country : <input type="text" name="born" /><br><br> Other Info: <input type="text" name="other" /><br><br> <input type="submit" name="Submit" value="Create" align="right"></td> </form> insert.php <?php mysql_connect ("localhost","root","") or die("Cannot connect to Database"); mysql_select_db ("test"); $sql="INSERT INTO memberdetails (username, firstname, surname, dob, totalwins, totalloses, email, country, info) VALUES ('$_POST[username]''$_POST[firstname]','$_POST[surname]','$_POST[wins]''$_POST[loses]''$_POST''$_POST[born]''$_POST[other]''$_POST[dob]')"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } echo "1 record added"; ?>
  14. I have created the login feature already, It works fine, I am just confused as how to add the admin feature, how do i direct only the admin to the deletemember.php page. The code below shows my login code it is very similar to the tutorial you used. Form code: <form name="form1" method="post" action="checklogin.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Member Login </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="myusername" type="text" id="myusername"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="mypassword" type="text" id="mypassword"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table> <br><br><center>Enter your usename and password....</center> Checklogin.php <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="test"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $username and $password, table row must be 1 row if($count==1){ // Register $username, $password and redirect to file "home.html" session_register("myusername"); session_register("mypassword"); header("location:home.php?myusername=" . $username); } else { echo "Wrong Username or Password"; } ?>
  15. hello, I have created a website which has to incorporate administration features. I hjave been trying to do this for a couple of days and any help will be much appreciated. I have a login screen (form) when the user enters their username and password they are brought to the homepage.php. Is there anyway to redirect the administrator (username=admin) to a different page from all ordinary members? e.g. deletemember.php Thanks
  16. Super il give it a try and get back to u!! thanks mate
  17. Thanks everyone!! working great. Smerny thats what I plan to do next, the user "admin" is the administrator of the site and will be the only one ablt to delete users. Any tips on this would be much appreciated. Should I have a page e.g. admindetails.php which the admin is directed to when he/she logs in, which has the delete function on this page and direct all other users to a getdetails.php where they can only view the details. Or is there a more simple way of doing this?
  18. When the user enters the username into the form and is redirected to getdetail.php there is a link at the bottom of the page to "delete user": <a href="delete.php">Delete User</a> Is $username declared on my getdetails.php? or do i have to declare it on my delete.php? Delete.php: <?php mysql_connect ("localhost","root","") or die("Cannot connect to Database"); mysql_select_db ("test"); mysql_query ("DELETE FROM members WHERE username='$username'") or die ("Error- user has not been deleted"); echo "User has been deleted"; //header("Location: personaldetails.php"); ?> When this function is working correctly should it delete the row completely from my database?
  19. AyKay47 just one more question.... I have tried to add a function to allow the user to delete the user form the database if required. The code I have used is: <?php mysql_connect ("localhost","root","") or die("Cannot connect to Database"); mysql_select_db ("test"); mysql_query ("DELETE FROM members WHERE username='$username'") or die (mysql_error)); echo "User has been deleted"; header("Location: personaldetails.php"); ?> This is giving me an error on the mysql_query line. I am not sure if i am using the correct format?
  20. Perfect Thanks mate Really appreciated!!
  21. form <table width="300" border="1" align="center" cellpadding="2" cellspacing="1" bgcolor="#9999cc"> <tr> <form name="form1" method="post" action="getdetails.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong><center>Personal Details</center> </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="username" type="text" id="username"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Get Details"></td> </tr> </table> </td> </form> </tr> </table>
  22. getdetails.php <html> <head> <link rel="stylesheet" type ="text/css" href="anything2.css" </head> <body> <div id="container"> <div id="header"><img src="imagesb.jpg" alt="Cool Image" align="left"> <img src="images.jpg" alt="Cool Image" align="right"><center><b><font size="6.5"><br><br>User Details</b></center></font> </div> <div id="leftnav"><center> <br><br> <input type= "button" style="width:120px;" value="Home" onClick="window.location= 'home.php' "> <br><br> <input type= "button" style="width:120px;" value="Club Details" onClick="window.location= 'clubdetails.php' "> <br><br> <input type= "button" style="width:120px;" value="Future Events" onClick="window.location= 'futureevents.php' "> <br><br> <input type= "button" style="width:120px;" value="News" onClick="window.location= 'news.php' "> <br><br> <input type= "button" style="width:120px;" value="FAQ" onClick="window.location= 'faq.php' "> <br><br> <input type= "button" style="width:120px;" value="Wall" onClick="window.location= 'wall.php' "> <br><br> <input type= "button" style="width:120px;" value="About Us" onClick="window.location= 'about.php' "> </div> <div id="body"> <br><br> <?php mysql_connect ("localhost","root","") or die("Cannot connect to Database"); mysql_select_db ("test"); if (isset($_POST['Submit'])){ $username=mysql_real_escape_string(trim($_POST['Submit'])); $sql = "select * from memberdetails WHERE username='$username'"; $result = mysql_query ($sql); while ($row = mysql_fetch_array($result)) { $username= $row["username"]; $firstname= $row["firstname"]; $surname= $row["surname"]; $dob= $row["dob"]; $totalwins= $row["totalwins"]; $totalloses= $row["totalloses"]; $email= $row["email"]; $country= $row["country"]; $info= $row["info"]; echo "<b><u>Username:</b></u> $username<br>"; echo "<b><u>Firstname:</b></u> $firstname<br>"; echo "<b><u>Surname: </b> </u> $surname<br>"; echo "<b><u>Date of Birth:</b></u> $dob<br>"; echo "<b><u>Total Chess Wins:</b></u> $totalwins<br>"; echo "<b><u>Total Chess loses:</b></u> $totalloses<br>"; echo "<b><u>Email Address: </b></u> $email<br>"; echo "<b><u>Born in: </b></u> $country<br>"; echo "<b><u>Other Details:</b></u> $info<br><br><br>"; }} ?> <a href="delete.php">Delete User</a> <div id="footer">This is the footer</div> </body> </html>
  23. Thanks my code is now <td width="294"><input name="username" type="text" id="username"></td> <td><input type="submit" name="Submit" value="Get Details"></td> But this is still not working, it was working perfectly yesterday.
  24. Hey I finally got this code working yesterday, when the user enters a name into the form and submits it the specific users details should be shown on the next page, this was working fine yesterday and when i turned my laptop on today it is not working, I am not getting any errors just not displaying the user details?? Any ideas? Heres the code Form: <table width="300" border="1" align="center" cellpadding="2" cellspacing="1" bgcolor="#9999cc"> <tr> <form name="form1" method="post" action="getdetails.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong><center>Personal Details</center> </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="submit" type="text" id="username"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Get Details"></td> </tr> </table> </td> </form> </tr> </table> getdetails.php <html> <head> <link rel="stylesheet" type ="text/css" href="anything2.css" </head> <body> <div id="container"> <div id="header"><img src="imagesb.jpg" alt="Cool Image" align="left"> <img src="images.jpg" alt="Cool Image" align="right"><center><b><font size="6.5"><br><br>User Details</b></center></font> </div> <div id="leftnav"><center> <br><br> <input type= "button" style="width:120px;" value="Home" onClick="window.location= 'home.php' "> <br><br> <input type= "button" style="width:120px;" value="Club Details" onClick="window.location= 'clubdetails.php' "> <br><br> <input type= "button" style="width:120px;" value="Future Events" onClick="window.location= 'futureevents.php' "> <br><br> <input type= "button" style="width:120px;" value="News" onClick="window.location= 'news.php' "> <br><br> <input type= "button" style="width:120px;" value="FAQ" onClick="window.location= 'faq.php' "> <br><br> <input type= "button" style="width:120px;" value="Wall" onClick="window.location= 'wall.php' "> <br><br> <input type= "button" style="width:120px;" value="About Us" onClick="window.location= 'about.php' "> </div> <div id="body"> <br><br> <?php mysql_connect ("localhost","root","") or die("Cannot connect to Database"); mysql_select_db ("test"); if (isset($_POST['Submit'])){ $username=mysql_real_escape_string(trim($_POST['Submit'])); $sql = "select * from memberdetails WHERE username='$username'"; $result = mysql_query ($sql); while ($row = mysql_fetch_array($result)) { $username= $row["username"]; $firstname= $row["firstname"]; $surname= $row["surname"]; $dob= $row["dob"]; $totalwins= $row["totalwins"]; $totalloses= $row["totalloses"]; $email= $row["email"]; $country= $row["country"]; $info= $row["info"]; echo "<b><u>Username:</b></u> $username<br>"; echo "<b><u>Firstname:</b></u> $firstname<br>"; echo "<b><u>Surname: </b> </u> $surname<br>"; echo "<b><u>Date of Birth:</b></u> $dob<br>"; echo "<b><u>Total Chess Wins:</b></u> $totalwins<br>"; echo "<b><u>Total Chess loses:</b></u> $totalloses<br>"; echo "<b><u>Email Address: </b></u> $email<br>"; echo "<b><u>Born in: </b></u> $country<br>"; echo "<b><u>Other Details:</b></u> $info<br><br><br>"; }} ?> <a href="delete.php">Delete User</a> <div id="footer">This is the footer</div> </body> </html>
×
×
  • 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.