Forum Moderators: coopster
I would like to fill the results into a text box, then have the user update those boxes and resubmit it to the database. Then display the changes in the same boxes on the same page. Its not going too well on what I thought was a seemingly simple problem....
<?php
$address = someone@hotmail.com;
$result = mysql_query("SELECT ID, Name, Age, height, weight FROM Individual WHERE Email = '$address'") or die(mysql_error());
$row = mysql_fetch_array($result);
print "<form name=\"updatePro\" action=\"updateProfile.php\" method=\"post\")";
print "Name: ";
<input type=\"text\" name=\"name\" value=\"$row[Name]\" />
print "age: ";
<input type=\"text\" name=\"age\" value=\"$row[Age]\" />
print "height: ";
<input type=\"text\" name=\"height\" value=\"$row[height]\" />
print "weight: ";
<input type=\"text\" name=\"weight\" value=\"$row[weight]\" />
print "</form>\n";
$result = mysql_query("UPDATE Individual SET Name = '$fname', Age =? Where Email = '$address' ");
?>
Not sure if that is how its done...well, that last part sure is wrong since I couldn't get the update to work....Any ideas on how to do this?
--Nick
print "<form name=\"updatePro\" action=\"updateProfile.php\" method=\"post\")";
becomes:
echo '<form name="updatePro" action="updateProfile.php" method="post")';
I switched after I got tired of commenting out quotation marks. Then, if you do want to include a PHP variable in what you're sending to the page, just do this:
'.$somevariable.'
For example:
$formname=updatePro;
echo '<form name="'.$formname.'" action="updateProfile.php" method="post")';
we do not see how looks: updateProfile.php
You are pointing to : updateProfile.php
So you need to feed updateProfile with your new data
print "<form name=\"updatePro\" action=\"updateProfile.php\" method=\"post\")";
the update file must contain the following to receive the values sent by the form
$username=$_POST['username'];
etc... one such per item....
then your DB section
$sql= "FROM Individual WHERE Email = '$address';
$sql = "update individual
and for example:
set username = '$username',
and the other var....
then
$result = mysql_query($sql, $conn);
if (!$result) {
print "There was a database error when executing <PRE>$sql</PRE>";
print mysql_error();
exit;