Msword Posted August 8, 2007 Share Posted August 8, 2007 editperson2.php <?php require("dbconnect.php"); mysql_select_db("runecrypt", $sql); if (isset($_POST['name'])) { echo "pid "; $pid = $_POST["pid"]; echo $pid; echo ' pid'; $name = $_POST["name"]; $pictureurl = $_POST["pictureurl"]; $exinfo = $_POST["exinfo"]; $dsc = $_POST["dsc"]; $location = $_POST["location"]; $quest = $_POST["quest"]; $membonly = $_POST["membonly"]; $contributors = $_POST["contributors"]; $lastupdate = date("F j, Y, g:i a"); echo 'hello'; mysql_query("UPDATE pdatabase SET name='$name' , pictureurl='$pictureurl' , exinfo='$exinfo' , dsc='$dsc', location='$location' , quest='$quest' , membonly='$membonly' , contributors='$contributors' , lastupdate='$lastupdate' WHERE pid='$pid'") or die("Mysql error"); } if (isset($_GET['pid'])) { echo "1312"; $pid = mysql_real_escape_string($_GET["pid"]); $result = mysql_query("SELECT * FROM pdatabase WHERE pid='$pid'") or die(mysql_error()); while($row = mysql_fetch_array($result)) { //<h2><span style=\"color: rgb(255, 0, 0);\"><a href="editperson.php">Refresh Page</a></span></h2> echo '<html> <head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <title>Add Person to Database</title> </head> <body> <div style="text-align: center;"> <form method="post" name="edit" action="editperson2.php"> Edit Person in Database<br> PID(Do not Edit) <input id="pid" value="' . $row['pid'] . '"/> <table style="text-align: left; margin-left: auto; margin-right: auto; height: 374px; width: 661px;" border="1" cellpadding="2" cellspacing="2"> <tbody> <tr> <td style="width: 140px; text-align: center;">Name</td> <td style="width: 415px; text-align: center;"><input value="' . $row['name'] . '" input maxlength="40" size="40" name="name"></td> </tr> <tr> <td style="width: 140px; text-align: center;">Picture Name</td> <td style="width: 415px; text-align: center;"><input value="' . $row['pictureurl'] . '" input maxlength="255" size="40" name="pictureurl"><span style="text-decoration: underline;"><br> </span><span style="font-family: monospace;">full link please(http://draftx.net/test/pictures/nopic.png)<br> nopic.png if none</span></td> </tr> <tr> <td style="width: 140px; text-align: center;">Examine Info</td> <td style="width: 415px; text-align: center;"><input value="' . $row['exinfo'] . '" textarea cols="40" rows="5" name="exinfo"></textarea><br> What it says when you examine the person</td> </tr> <tr> <td style="width: 140px; text-align: center;">Description</td> <td style="width: 415px; text-align: center;"><input value="' . $row['dsc'] . '" textarea cols="40" rows="5" name="dsc"></textarea><br> About the person, any extra information</td> </tr> <tr> <td style="width: 140px; text-align: center;">Location</td> <td style="width: 415px; text-align: center;"><input value="' . $row['location'] . '" input maxlength="50" size="40" name="location"><br> <pre><a href="AreaURL">AreaName</a></pre> </td> </tr> <tr> <td style="width: 140px; text-align: center;">Quests</td> <td style="width: 415px; text-align: center;"><input value="' . $row['quest'] . '" textarea cols="40" rows="5" name="quest"></textarea><br> <pre><a href="QuestURL">QuestName</a><br>Put <br> after every line<br>None if person is involved in no quests</pre> </td> </tr> <tr> <td style="width: 140px; text-align: center;">Members Only</td> <td style="width: 415px; text-align: center;"><input value="' . $row['membonly'] . '" input maxlength="5" size="5" name="membonly"><br> Yes/No</td> </tr> <tr> <td style="text-align: center;">Contributors</td> <td style="text-align: center;"><input value="' . $row['contributors'] . '" textarea cols="40" rows="5" name="contributors"></textarea><br> <pre><a href="ContibutorForumURL">ContributorName</a></pre> </td> </tr> </tbody> </table> <input value="Submit" type="submit"></form> </div> </body> </html>'; } } ?> editperson1.php <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title></title> </head> <body> <form method="get" action="editperson2.php" name="edit"> <table style="text-align: left; margin-left: auto; margin-right: auto; width: 325px; height: 61px;" border="1" cellpadding="2" cellspacing="2"> <tbody> <tr> <td style="text-align: center;">Person to edit PID</td> <td><input name="pid"></td> </tr> </tbody> </table> <div style="text-align: center;"><input value="Submit" action="addperson.php" type="submit"><br> </div> </form> <form method="get" name="edit"></form> </body> </html> On editperson 2, on line 7 (echo $pid;) it isn't showing anything, whats wrong? It can echo the name variable, so there must be something wrong just with the pid part. I changed the form to get to check, and no pid specified. wth The URL this is at is draftx.net/test/ Quote Link to comment https://forums.phpfreaks.com/topic/63922-solved-form-problem/ Share on other sites More sharing options...
lemmin Posted August 8, 2007 Share Posted August 8, 2007 You are using the GET method for the PID and requesting it from the POST variable array.You also have two forms with the same name. It probably isn't hurting anything, but the second one would cause problems if you tried to use any javascript with it. And you have an "action" property in a input tag, I am almost certain that does nothing. Good luck, hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/63922-solved-form-problem/#findComment-318588 Share on other sites More sharing options...
MadTechie Posted August 8, 2007 Share Posted August 8, 2007 method="get" to method="post" as lemmin said Quote Link to comment https://forums.phpfreaks.com/topic/63922-solved-form-problem/#findComment-318593 Share on other sites More sharing options...
Msword Posted August 8, 2007 Author Share Posted August 8, 2007 Could you tell me specific lines or something, because i'm using GET for the first form, and POST for the second. I want it to be easy to just type in the variable in the url to get there, but it is a little 2 big for get i think on the second for so i used POST Current code: <?php require("dbconnect.php"); mysql_select_db("runecrypt", $sql); if (isset($_POST['name'])) { echo "pid "; $pid = $_POST["id"]; echo $pid; echo ' pid'; $name = $_POST["name"]; $pictureurl = $_POST["pictureurl"]; $exinfo = $_POST["exinfo"]; $dsc = $_POST["dsc"]; $location = $_POST["location"]; $quest = $_POST["quest"]; $membonly = $_POST["membonly"]; $contributors = $_POST["contributors"]; $lastupdate = date("F j, Y, g:i a"); echo 'hello'; mysql_query("UPDATE pdatabase SET name='$name' , pictureurl='$pictureurl' , exinfo='$exinfo' , dsc='$dsc', location='$location' , quest='$quest' , membonly='$membonly' , contributors='$contributors' , lastupdate='$lastupdate' WHERE pid='$pid'") or die("Mysql error"); } if (isset($_GET['pid'])) { echo "1312"; $pid = mysql_real_escape_string($_GET["pid"]); $result = mysql_query("SELECT * FROM pdatabase WHERE pid='$pid'") or die(mysql_error()); while($row = mysql_fetch_array($result)) { //<h2><span style=\"color: rgb(255, 0, 0);\"><a href="editperson.php">Refresh Page</a></span></h2> echo '<html> <head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <title>Add Person to Database</title> </head> <body> <div style="text-align: center;"> <form method="post" name="edit2" action="editperson2.php"> Edit Person in Database<br> PID(Do not Edit) <input id="id" value="' . $row['pid'] . '"/> <table style="text-align: left; margin-left: auto; margin-right: auto; height: 374px; width: 661px;" border="1" cellpadding="2" cellspacing="2"> <tbody> <tr> <td style="width: 140px; text-align: center;">Name</td> <td style="width: 415px; text-align: center;"><input value="' . $row['name'] . '" input maxlength="40" size="40" name="name"></td> </tr> <tr> <td style="width: 140px; text-align: center;">Picture Name</td> <td style="width: 415px; text-align: center;"><input value="' . $row['pictureurl'] . '" input maxlength="255" size="40" name="pictureurl"><span style="text-decoration: underline;"><br> </span><span style="font-family: monospace;">full link please(http://draftx.net/test/pictures/nopic.png)<br> nopic.png if none</span></td> </tr> <tr> <td style="width: 140px; text-align: center;">Examine Info</td> <td style="width: 415px; text-align: center;"><input value="' . $row['exinfo'] . '" textarea cols="40" rows="5" name="exinfo"></textarea><br> What it says when you examine the person</td> </tr> <tr> <td style="width: 140px; text-align: center;">Description</td> <td style="width: 415px; text-align: center;"><input value="' . $row['dsc'] . '" textarea cols="40" rows="5" name="dsc"></textarea><br> About the person, any extra information</td> </tr> <tr> <td style="width: 140px; text-align: center;">Location</td> <td style="width: 415px; text-align: center;"><input value="' . $row['location'] . '" input maxlength="50" size="40" name="location"><br> <pre><a href="AreaURL">AreaName</a></pre> </td> </tr> <tr> <td style="width: 140px; text-align: center;">Quests</td> <td style="width: 415px; text-align: center;"><input value="' . $row['quest'] . '" textarea cols="40" rows="5" name="quest"></textarea><br> <pre><a href="QuestURL">QuestName</a><br>Put <br> after every line<br>None if person is involved in no quests</pre> </td> </tr> <tr> <td style="width: 140px; text-align: center;">Members Only</td> <td style="width: 415px; text-align: center;"><input value="' . $row['membonly'] . '" input maxlength="5" size="5" name="membonly"><br> Yes/No</td> </tr> <tr> <td style="text-align: center;">Contributors</td> <td style="text-align: center;"><input value="' . $row['contributors'] . '" textarea cols="40" rows="5" name="contributors"></textarea><br> <pre><a href="ContibutorForumURL">ContributorName</a></pre> </td> </tr> </tbody> </table> <input value="Submit" type="submit"></form> </div> </body> </html>'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title></title> </head> <body> <form method="get" action="editperson2.php" name="edit1"> <table style="text-align: left; margin-left: auto; margin-right: auto; width: 325px; height: 61px;" border="1" cellpadding="2" cellspacing="2"> <tbody> <tr> <td style="text-align: center;">Person to edit PID</td> <td><input name="pid"></td> </tr> </tbody> </table> <div style="text-align: center;"><input value="Submit" type="submit"><br> </div> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/63922-solved-form-problem/#findComment-318601 Share on other sites More sharing options...
MadTechie Posted August 8, 2007 Share Posted August 8, 2007 i have added some comments <?php require("dbconnect.php"); mysql_select_db("runecrypt", $sql); if (isset($_POST['name'])) { //assume its an int $pid = (int)$_POST["id"]; echo "POST: pid=".$pid; $name = $_POST["name"]; $pictureurl = $_POST["pictureurl"]; $exinfo = $_POST["exinfo"]; $dsc = $_POST["dsc"]; $location = $_POST["location"]; $quest = $_POST["quest"]; $membonly = $_POST["membonly"]; $contributors = $_POST["contributors"]; $lastupdate = date("F j, Y, g:i a"); //SQL injections problmes here please filter the above code mysql_query("UPDATE pdatabase SET name='$name' , pictureurl='$pictureurl' , exinfo='$exinfo' , dsc='$dsc', location='$location' , quest='$quest' , membonly='$membonly' , contributors='$contributors' , lastupdate='$lastupdate' WHERE pid='$pid'") or die("Mysql error"); } if (isset($_GET['pid'])) { //assume its an int $pid = (int)$_GET['pid']; echo "GET: pid=".$pid; //$pid = mysql_real_escape_string($_GET["pid"]); $result = mysql_query("SELECT * FROM pdatabase WHERE pid='$pid'") or die(mysql_error()); while($row = mysql_fetch_array($result)) { //<h2><span style=\"color: rgb(255, 0, 0);\"><a href="editperson.php">Refresh Page</a></span></h2> echo '<html> <head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <title>Add Person to Database</title> </head> <body> <div style="text-align: center;"> <form method="post" name="edit2" action="editperson2.php"> Edit Person in Database<br> PID(Do not Edit) <input id="id" value="' . $row['pid'] . '"/> <table style="text-align: left; margin-left: auto; margin-right: auto; height: 374px; width: 661px;" border="1" cellpadding="2" cellspacing="2"> <tbody> <tr> <td style="width: 140px; text-align: center;">Name</td> <td style="width: 415px; text-align: center;"><input value="' . $row['name'] . '" input maxlength="40" size="40" name="name"></td> </tr> <tr> <td style="width: 140px; text-align: center;">Picture Name</td> <td style="width: 415px; text-align: center;"><input value="' . $row['pictureurl'] . '" input maxlength="255" size="40" name="pictureurl"><span style="text-decoration: underline;"><br> </span><span style="font-family: monospace;">full link please(http://draftx.net/test/pictures/nopic.png)<br> nopic.png if none</span></td> </tr> <tr> <td style="width: 140px; text-align: center;">Examine Info</td> <td style="width: 415px; text-align: center;"><input value="' . $row['exinfo'] . '" textarea cols="40" rows="5" name="exinfo"></textarea><br> What it says when you examine the person</td> </tr> <tr> <td style="width: 140px; text-align: center;">Description</td> <td style="width: 415px; text-align: center;"><input value="' . $row['dsc'] . '" textarea cols="40" rows="5" name="dsc"></textarea><br> About the person, any extra information</td> </tr> <tr> <td style="width: 140px; text-align: center;">Location</td> <td style="width: 415px; text-align: center;"><input value="' . $row['location'] . '" input maxlength="50" size="40" name="location"><br> <pre><a href="AreaURL">AreaName</a></pre> </td> </tr> <tr> <td style="width: 140px; text-align: center;">Quests</td> <td style="width: 415px; text-align: center;"><input value="' . $row['quest'] . '" textarea cols="40" rows="5" name="quest"></textarea><br> <pre><a href="QuestURL">QuestName</a><br>Put <br> after every line<br>None if person is involved in no quests</pre> </td> </tr> <tr> <td style="width: 140px; text-align: center;">Members Only</td> <td style="width: 415px; text-align: center;"><input value="' . $row['membonly'] . '" input maxlength="5" size="5" name="membonly"><br> Yes/No</td> </tr> <tr> <td style="text-align: center;">Contributors</td> <td style="text-align: center;"><input value="' . $row['contributors'] . '" textarea cols="40" rows="5" name="contributors"></textarea><br> <pre><a href="ContibutorForumURL">ContributorName</a></pre> </td> </tr> </tbody> </table> <input value="Submit" type="submit"></form> </div> </body> </html>'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/63922-solved-form-problem/#findComment-318615 Share on other sites More sharing options...
Msword Posted August 8, 2007 Author Share Posted August 8, 2007 STill not working, i know security is an issue, i'm going to be making a login system when i have everything working, which, atm i dont. POST: pid=0 Quote Link to comment https://forums.phpfreaks.com/topic/63922-solved-form-problem/#findComment-318624 Share on other sites More sharing options...
MadTechie Posted August 8, 2007 Share Posted August 8, 2007 add print_r($_POST); at the top also you make want to change <input id="id" value="' . $row['pid'] . '"/> to <input id="id" name="id" value="' . $row['pid'] . '"/> Quote Link to comment https://forums.phpfreaks.com/topic/63922-solved-form-problem/#findComment-318635 Share on other sites More sharing options...
Msword Posted August 8, 2007 Author Share Posted August 8, 2007 Array ( [name] => Man [pictureurl] => http://draftx.net/test/pictures/nopic.png [exinfo] => look at the little noob [dsc] => Theive the man when you need some cash [location] => All around the world [quest] => http://www.runecrypt.com/index.php?pid=49 [membonly] => Yes [contributors] => Msword, others ) No id... i changed what you told me 2 also i'm getting really really frustrated with this script, i have spent at least 3 hours on it, doing this exclusively. How can i fix the stupid thing. Quote Link to comment https://forums.phpfreaks.com/topic/63922-solved-form-problem/#findComment-318640 Share on other sites More sharing options...
MadTechie Posted August 8, 2007 Share Posted August 8, 2007 Hummmm try PID(Do not Edit) <input id="id" value="' . $row['pid'] . '"/> to PID(Do not Edit) <input name="id" value="' . $pid . '"/> i assume when you use the ?pid=123 it displays 123 in the form! Quote Link to comment https://forums.phpfreaks.com/topic/63922-solved-form-problem/#findComment-318647 Share on other sites More sharing options...
Msword Posted August 8, 2007 Author Share Posted August 8, 2007 OMG, thanks you soooooo much. I was about to explode. Dude your awesome thanks for all your help, that worked Quote Link to comment https://forums.phpfreaks.com/topic/63922-solved-form-problem/#findComment-318652 Share on other sites More sharing options...
MadTechie Posted August 8, 2007 Share Posted August 8, 2007 WooHoo, happy to help Quote Link to comment https://forums.phpfreaks.com/topic/63922-solved-form-problem/#findComment-318654 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.