473,606 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I having problem updating User Records

41 New Member
Hi, everyone I've been trying to figure out a way for a user to update there information. I'm using sections to identify the specific user..Here is the form

[HTML]
<?
include("includ e/session.php");
?>
<?
$username="xxxx xx";
$password="xxxx xxx";
$database="xxxx x";
mysql_connect(l ocalhost,$usern ame,$password);

$query=" SELECT * FROM pix WHERE username='$sess ion->username'";
$result=mysql_q uery($query);
$num=mysql_numr ows($result);
mysql_close();

$i=0;
while ($i < $num) {
$whatsit=mysql_ result($result, $i,"whatsit");
$firstname=mysq l_result($resul t,$i,"firstname ");
$lastname=mysql _result($result ,$i,"lastname") ;
$phonenumber=my sql_result($res ult,$i,"phonenu mber");
$address=mysql_ result($result, $i,"address");
$retail=mysql_r esult($result,$ i,"retail");
$city=mysql_res ult($result,$i, "city");
$state=mysql_re sult($result,$i ,"state");
$zip=mysql_resu lt($result,$i," zip");

++$i;
}
?>

<html>
<head>
<title>Untitled </title>
<style>
body {
font: 81% verdana, arial, sans-serif;
background-color: #fff;
margin: 10px;
padding: 4px;
}
</style>
</head>
<body>
<?php
if($session->logged_in){
echo "<table align=LEFT width=670 height=350 bgcolor=ffffff BORDER=1 BORDERCOLOR=eae aea cellpadding=5>" ;
echo "<tr>";
echo " <td bgcolor=#dddddd ><img src=\"http://www.atlantasund ergroundhitseco mmerce.com/flash_mp3_playe r/store copy.jpg\" width=667 height=128 alt= border=1><br>
</td>";
echo "</tr>";
echo "<tr>";
echo "<td align=center bgcolor=#dddddd ><b><font color=gray size=1>Register s (Personal)Payme nt Information</font></b><br>
</td>";
echo "</tr>";
echo "<tr>";
echo "<td bgcolor=eaeaea> <font color=gray size=1>All payments from Atlanta's UnderGround Hits to the register will be mailed to the following address. It is the responsiblity of the
register to contact Atlanta's UnderGround Hits should their address change during the distribution period. <br><font color=red>It is important this information is valid.</font>
</td>";
echo "</tr>";
echo "<tr>";
echo "<td>
<form enctype=multipa rt/form-data action=\"update _artistinfo.php \" method=\"post\" >
<font color=gray size=2>First Name :&nbsp;&nbsp; </font><input name=\"ud_first name\" value=\"$firstn ame\">&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; <font color=gray size=2>E-Mail: <input name=\"ud_email \" value=\"$email\ ">
</td>";
echo "</tr>";
echo "<tr>";
echo "<td><font color=gray size=2>Last Name :&nbsp;&nbsp; </font><input name=\"ud_lastn ame\"value=\"$l astname\">&nbsp ;&nbsp;&nbsp;&n bsp;<font color=gray size=2>Phone Number :&nbsp;</font><input name=\"ud_phone number\" value=\"$phonen umber\"></td>";
echo "</tr>";
echo "<tr>";
echo "<td><font color=gray size=2>Address :</font>&nbsp;&nbs p;&nbsp;&nbsp;< input name=\"ud_addre ss\" value=\"$addres s\">&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;<font color=gray size=2>Album Retail:&nbsp;</font><input name=\"ud_retai l\" value=\"$retail \"></td>";
echo "</tr>";
echo "<tr>";
echo "<td><font color=gray size=2>City :<font>&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ; <input name=\"ud_city\ " value=\"$city\" >
</td>";
echo "</tr>";
echo "<tr>";
echo "<td><font color=gray size=2>State :&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;</font><SELECT name=\"ud_state \">
<option>$stat e</option>
<option value=\"AL\">AL ABAMA</option>
</select></td>";
echo "</tr>";
echo "<tr>";
echo "<td><font color=gray size=2>ZIP CODE:<font>&nbs p;&nbsp;<input name=\"ud_zip\" value=\"$zip\"> </td>";
echo "</tr>";
echo "<tr>";
echo "<td bgcolor=>
<br><br><font size=2 color=gray><b>U ser:</b>&nbsp;&nbsp;& nbsp;</font>
<SELECT name=\"ud_usern ame\">
<option>$sessio n->username</option>
</select></td>";
echo "</tr>";
echo "<tr>";
echo "<td bgcolor=><hr color=eaeaea><f ont color=gray size=1>Once you have completed the above your will be ready to submit your information. You will then be direct to the album upload section of the Online Registartion.
Your total album upload can be no more than 50 megs. Click the below submit to proceed. </font></td>";
echo "</tr>";
echo "<td>
<input type=submit value=Submit>
</form>
</td>";
echo "</tr>";
echo "</table>";
}
else{
?>
<TABLE>
<TR>
<Td>
<h1>Login</h1>
<?
/**
* User not logged in, display the login form.
* If user has already tried to login, but errors were
* found, display the total number of errors.
* If errors occurred, they will be displayed.
*/
if($form->num_errors > 0){
echo "<font size=\"2\" color=\"#ff0000 \">".$form->num_errors." error(s) found</font>";
}
?>
<form action="process .php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3" >
<tr><td>Usernam e:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user" ); ?>"></td><td><? echo $form->error("user" ); ?></td></tr>
<tr><td>Passwor d:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass" ); ?>"></td><td><? echo $form->error("pass" ); ?></td></tr>
<tr><td colspan="2" align="left"><i nput type="checkbox" name="remember" <? if($form->value("remembe r") != ""){ echo "checked"; } ?>>
<font size="2">Rememb er me next time &nbsp;&nbsp;&nb sp;&nbsp;
<input type="hidden" name="sublogin" value="1">
<input type="submit" value="Login"></td></tr>
<tr><td colspan="2" align="left"><b r><font size="2">[<a class=T1 href="forgotpas s.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
<tr><td colspan="2" align="left"><b r>Not registered? <a class=T1 href="register. php">Sign-Up!</a></td></tr>
</table>
</form>

<?
}

/**
* Just a little page footer, tells how many registered members
* there are, how many users currently logged in and viewing site,
* and how many guests viewing site. Active users are displayed,
* with link to their user information.
*/
echo "</td></tr><tr><td align=\"center\ " class=T1><br><b r>";
echo "<b>Update your profile information <br>";
?>
</td></tr>
</table>
</body>
</html>
[/HTML]
The form displays the current information the user has stored in the DB. Once the user makes changes this is the PHP SCRIPT that should update the database.

[PHP]
<?php
// check to see if the form was posted with the correct id's
if (isset($_POST['_submit']) AND isset($_REQUEST['ud_username']) ) {
$ud_username = intval($_REQUES T['ud_username']);
if ($ud_username < 0) {

# escape data and set variables
$ud_username = addslashes($_PO ST["ud_usernam e"]);
$ud_firstname = addslashes($_PO ST["ud_firstna me"]);
$ud_email = addslashes($_PO ST["ud_email"]);
$ud_lastname = addslashes($_PO ST["ud_lastnam e"]);
$ud_phonenumber = addslashes($_PO ST["ud_phonenumber "]);
$ud_address = addslashes($_PO ST["ud_address "]);
$ud_retail = addslashes($_PO ST["ud_retail"]);
$ud_city = addslashes($_PO ST["ud_city"]);
$ud_state = addslashes($_PO ST["ud_state"]);
$ud_zip = addslashes($_PO ST["ud_zip"]);

$usr = "xxxxxxx";
$pwd = "xxxxx";
$db = "xxxxx";
$host = "xxxx";
// connect to database server
$cid = mysql_connect($ host,$usr,$pwd)
or die("Server connnect ERROR: " . mysql_error());
// select the database
mysql_select_db ($db)
or die("Database select ERROR: " . mysql_error());
$query="UPDATE pix SET firstname='$ud_ firstname', email='$ud_emai l', lastname='$ud_l astname', phonenumber='$u d_phonenumber', address='$ud_ad dress', retail='$ud_ret ail', city='$ud_city' , state='$ud_stat e', zip='$ud_zip' WHERE username= '$ud_username'" ;
mysql_query($qu ery);
echo "Record Updated";
mysql_close();
++$i;
}
?>
[/PHP]

but when clicked nothing happens. The information is not being updated in the database. Could a brotha get a little help on this one!!!! It seems simply so I know I making a small mistake.

Thank You
Jan 19 '07 #1
2 1832
ronverdonk
4,258 Recognized Expert Specialist
1. why don't you append the mysql_error() to the UPDATE statement[php]mysql_query($qu ery) or die
"Update error: ".mysql_error() ;[/php] so you know it is / or not an update error

2. when the form is not submitted correctly, i.e. where is the ELSE branch of this statement[php]if (isset($_POST['_submit']) AND isset($_REQUEST['ud_username']) ) {[/php]

3. I cannot find the close brace of the IF statement nor the ELSE of that statement.

In cases 2 and 3 your script ends without action or message.

Ronald :cool:
Jan 19 '07 #2
underground
41 New Member
Problemed solved..Thanks again Ronald !
Jan 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
16138
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? 1) simply UPDATING the values for all fields in the table, whether or not any particular field has actually changed 2) running a second SELECT statement and comparing the $_POST vars to the returned values, and only UPDATING those that have...
6
5762
by: Hennie de Nooijer | last post by:
Hi, Currently we're a building a metadatadriven datawarehouse in SQL Server 2000. We're investigating the possibility of the updating tables with enormeous number of updates and insert and the use of checkpoints (for simple recovery and Backup Log for full recovery). On several website people speak about full transaction log and the pace of growing can't keep up with the update. Therefore we want to create a script which flushes the...
1
1857
by: Chris Jackson | last post by:
I'm a novice Access user and am not sure how to solve the following problem. Any help with the following would be greatly appreciated! I have two tables with identical structures, the first holds the data input for a questionnaire, the second holds the scores from the questionnaire, to move the scores I've set up 2 action queries, the first appends the record to the second table, the second action query 'updates' the results by...
5
3290
by: Lyn | last post by:
This one is difficult to explain, so I will cut it down to the basics. I have a major table 'tblA' which has an autonum field 'ID-A' as primary key (of no significance to users). 'tblA' contains many fields including picture and memo fields. The main user-selectable field is 'NameA'. There is also a crossreference table (let's call it 'tblB') which provides a secondary method of accessing records in 'tblA'. The main fields in 'tblB'...
1
1502
by: davidgordon | last post by:
Hi, If I am updating a list of records for a user on an asp page, is there a way to hold the page updating, even if they refresh the page, until I have updated all the records. i.e. rather than them seeing records change 1 at a time if they refreshed their page, all the records would update together in 1 go, a bit like a batch update ?
1
1824
by: beil.jp | last post by:
Hi All - I'm new to Google Groups and just a novice user of Access, so please forgive me if my question is elementary: I am having a problem using the "update query" for my first time. In my database, I have two tables. Both of the tables have duplicate data, though the "Initial Data" table has many more records than the "Filter Two" table due to a process of elimination that has occurred in the past week. Both tables have 5 colums...
5
1975
by: JimmyKoolPantz | last post by:
Situation: I am writing a program that opens up a data file (file ext .dbf), imports the information into a dataset. The program also, searches through the dataset for key words ("company names") and then displays all records with company names in a datagridview. Once the information has been binded to the datagridview control, I allow the user to select all records that are not companies, for example, during the search the key word...
2
1462
by: najimou | last post by:
Hi I have a subform where the user make changes to several filtered records in view. when clicking the updating button, I run the update query to perform some calculations and update the table for only those filtered records. however with an update query, its only updating to the first record in view. any workaround for this problem? much appreciated
5
2901
by: Bill Schanks | last post by:
I have a winform app (VB 2005) that allows users to export data to excel, make updates to the excel file and import the data from that Excel file and update the database. My question is: Is it best to do it this way, calling the update stored procedure for every update? Or should I be loading this data into a staging table, and if all goes well do the 'Real' Update. Or put this into a data adapter and update from that? The application...
0
8432
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8428
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8299
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6753
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5456
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3919
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3964
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2442
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1548
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.