Current location: Hot Scripts Forums » Programming Languages » PHP » Urgent! Update fields problem


Urgent! Update fields problem

Reply
  #1 (permalink)  
Old 05-10-04, 03:52 PM
Ogmios Ogmios is offline
Newbie Coder
 
Join Date: May 2004
Location: Southern Illinois
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Urgent! Update fields problem

Help! I have my final project due in class very soon(tomorrowish) and I have spent a week trying to figure out this problem!

What I am trying to do is to have users type a first and last name on one page, then have the information for that name be filled in on the next page, so it can be easily updated. However, the only way I can think to place the information in the form makes it so that whenever I click 'Submit' after changing some fields, the fields go right back to the way they were. Can anyone help me?

Here's my code:

The first page:

<?php
if($action=="selectemployee"){
//Login script

mysql_connect("localhost","rtcstudent","student");
mysql_select_db("intranet");
if (!$fname || !$lname) {
echo "Please fill out all fields.";
exit;
}
session_start();
session_register("fname");
session_register("lname");
header('location:updateemployee.php');
}

?>
<HTML>
<HEAD>
</HEAD>
<BODY>
<TABLE>
<FORM name="selectupdate" action="selectupdate.php" method="post">
<TR>
<TD>
First Name:
</TD>
<TD>
<INPUT TYPE="text" name="fname" value="" size="30">
</TD>
</TR><TR>
<TD>
Last Name:
</TD>
<TD>
<Input type="text" name="lname" Value="" SIZE="30">
</TD>
</TR>
<TR>
<TD>
<INPUT type="hidden" name="action" value="selectemployee">
</TD>
<TD>
<INPUT class="button" type="submit" name="submit" value="search">
</TD>
</TR>
</FORM>
</TABLE>
</BODY>
</HTML>

And the second page:

<?php
session_start();

//Login script
if(session_is_registered('lname')){
if(session_is_registered('fname')){


mysql_connect("localhost","rtcstudent","student");
mysql_select_db("intranet");

$sql = mysql_query("SELECT * FROM intranet where fname='$fname' AND lname='$lname'");
while($intranetArray = mysql_fetch_array($sql)){
if($intranetArray == 0) {
echo "No More Employees Found With This Last Name";
exit;
}
else{
$vuname = $intranetArray['username'];
$vpword = $intranetArray['password'];
$vfname = $intranetArray['fname'];
$vlname = $intranetArray['lname'];
$vstreet = $intranetArray['street'];
$vcity = $intranetArray['city'];
$vstate = $intranetArray['state'];
$vzip = $intranetArray['zip'];
$vphone = $intranetArray['phone'];
$vemail = $intranetArray['email'];
$vdept = $intranetArray['dept'];
$vsalary = $intranetArray['salary'];

}

}
}
else{
echo "Error";
}

if($update){

mysql_connect("localhost","rtcstudent","student");
mysql_select_db("intranet");
$sql = "UPDATE intranet SET username='".$vuname."',password='".$vpword."',fnam e='".$vfname."',lname='".$vlname."',street='".$vst reet."',city='".$vcity."',state='".$vstate."',zip= '".$vzip."',phone='".$vphone."',email='".$vemail." ',dept='".$vdept."',salary='".$vsalary."' WHERE fname LIKE '$fname' AND lname LIKE '$lname'" or die("Query Failed: " . mysql_error() );
mysql_query($sql);
}
}
?>
<HTML>
<HEAD>
</HEAD>
<BODY>
<TABLE>
<FORM name='updateemployee' action='updateemployee.php' method='post'>
<input type='hidden' name='intranet' value='<?php $intranet ?>'>
<TR>
<TD>
Username:
</TD>
<TD>
<Input type='text' name='uname' value="<?php echo $vuname?>" SIZE='30'>
</TD>
</TR>
<TR>
<TD>
Password:
</TD>
<TD>
<Input type='text' name='pword' value="<?php echo $vpword?>" SIZE='30'>
</TD>
</TR>
<TR>
<TD>
First Name:
</TD>
<TD>
<Input type='text' name='pfname' value="<?php echo $vfname?>" SIZE='30'>
</TD>
</TR>
<TR>
<TD>
Last Name:
</TD>
<TD>
<Input type='text' name='plname' value="<?php echo $vlname?>" SIZE='30'>
</TD>
</TR>
<TR>
<TD>
Street Address:
</TD>
<TD>
<Input type='text' name='street' value="<?php echo $vstreet?>" SIZE='30'>
</TD>
</TR>
<TR>
<TD>
City:
</TD>
<TD>
<Input type='text' name='city' value="<?php echo $vcity?>" SIZE='30'>
</TD>
</TR>
<TR>
<TD>
State:
</TD>
<TD>
<Input type='text' name='state' value="<?php echo $vstate?>" SIZE='30'>
</TD>
</TR>
<TR>
<TD>
Zip:
</TD>
<TD>
<Input type='text' name='zip' value="<?php echo $vzip?>" SIZE='30'>
</TD>
</TR>
<TR>
<TD>
Phone:
</TD>
<TD>
<Input type='text' name='phone' value="<?php echo $vphone?>" SIZE='30'>
</TD>
</TR>
<TR>
<TD>
Email:
</TD>
<TD>
<Input type='text' name='email' value="<?php echo $vemail?>" SIZE='30'>
</TD>
</TR>
<TR>
<TD>
Department:
</TD>
<TD>
<Input type='text' name='dept1' value="<?php echo $vdept?>" SIZE='30'>
</TD>
</TR>
<TR>
<TD>
Salary:
</TD>
<TD>
<Input type='text' name='salary' value="<?php echo $vsalary?>" SIZE='30'>
</TD>
</TR>
<TR>
<TD>
<INPUT type='submit' name='submit' value='submit'>
</TD>
</TR>
</FORM>
</TABLE>
</BODY>
</HTML>


Thank you for your time
Ogmios
Reply With Quote
  #2 (permalink)  
Old 05-12-04, 12:59 AM
Ogmios Ogmios is offline
Newbie Coder
 
Join Date: May 2004
Location: Southern Illinois
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Disregard earlier statement of 'Nevermind'

Thought i had it figured out, and posted so, but it still didn't work

Ogmios

Last edited by Ogmios; 05-12-04 at 01:02 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem getting data from DataGrid on update petersza ASP.NET 5 10-19-04 11:37 PM
formmail problem gscraper Perl 12 08-27-04 03:06 AM
help! urgent.. how to select next 50 records? angela ASP 3 04-24-04 12:58 PM
Compare and update perleo PHP 2 10-27-03 03:53 AM
type mismatch and update loop - HELP! seala ASP 1 09-22-03 05:27 PM


All times are GMT -5. The time now is 10:32 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.