Jump to content

Recommended Posts

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/

Link to comment
https://forums.phpfreaks.com/topic/63922-solved-form-problem/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/63922-solved-form-problem/#findComment-318588
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/63922-solved-form-problem/#findComment-318601
Share on other sites

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>';
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/63922-solved-form-problem/#findComment-318615
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/63922-solved-form-problem/#findComment-318640
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.