Jump to content

updating user information php/mySQL


NickG21

Recommended Posts

hey everyone,

        im fairly new to the incorporation of php and mySQL and i am looking to start off by making a user info database that will hold contact information as well as a username and password field.  below is the code for the site i want to use to allow the user to "update" their info.  My problem is when i click the link to "edit" info after the user has logged in, the page displays blank.  here is my code, any help is much appreciated.  thanks in advance.

 

<?php
include("dbinfo.inc.php");
mysql_connect($host,$dbusername,$dbpassword);
@mysql_select_db($database) or die( "Unable to select database");
$query= "SELECT * FROM ContactInfo WHERE username='$user'";
$result= mysql_query($query);
$num = mysql_num_rows($result); 
mysql_close();

$i=0;
while ($i < $num) {
$first=mysql_result($result,$i,"ud_first");
$last=mysql_result($result,$i,"ud_last");
$address=mysql_result($result,$i,"ud_address");
$city=mysql_result($result,$i,"ud_city");
$state=mysql_result($result,$i,"ud_state");
$zip=mysql_result($result,$i,"ud_zip");
$country=mysql_result($result,$i,"ud_country");
$email=mysql_result($result,$i,"ud_email");
$phone=mysql_result($result,$i,"ud_phone");
$fax=mysql_result($result,$i,"ud_fax");



?>

<form action="update.php">
<input type="hidden" name="ud_id" value="<? echo "$id"; ?>">
First Name: <input type="text" name="ud_first" value="<? echo "$first"?>"><br>
Last Name: <input type="text" name="ud_last" value="<? echo "$last"?>"><br>
Address: <input type="text" name="ud_address" value="<? echo "$address"?>"><br>
City: <input type="text" name="ud_city" value="<? echo "$city"?>"><br>
State: <input type="text" name="ud_state" value="<? echo "$state"?>"><br>
Zip: <input type="text" name="ud_zip" value="<? echo "$zip"?>"><br>
Country: <input type="text" name="ud_country" value="<? echo "$country"?>"><br>
E-mail: <input type="text" name="ud_email" value="<? echo "$email"?>"><br>
Phone Number: <input type="text" name="ud_phone" value="<? echo "$phone"?>"><br>
Fax Number: <input type="text" name="ud_fax" value="<? echo "$fax"?>"><br>

<input type="Submit" value="Update">
</form>

<?
$i++;
} 
?>

Link to comment
https://forums.phpfreaks.com/topic/41315-updating-user-information-phpmysql/
Share on other sites

$query= "SELECT * FROM ContactInfo WHERE username='$user'";
$result= mysql_query($query);
$num = mysql_num_rows($result); 

 

$num is supposed to be the value of the username that is selected from the database so it can then take the information linked with it and redisplay on the page to be updated.

Archived

This topic is now archived and is closed to further replies.

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