hi there, im a final year student doing a project on email system using php. i dont hv any basic in php. im trying to update the user record in the database table but its not working..please help me coz i need 2 show my progress to my supervisor next week.
he is my coding...
emailUpdateProfile.php
<? session_start();
// START PHP CODES. THIS PART MUST ON THE TOP OF THIS PAGE.
// Connect database.
include("condb.php");
$userID=$_SESSION['userID'];
$query="select * from generalcontact where userID='$userID'";
$result=mysql_query($query, $connect);
if($result){
if($array=mysql_fetch_array($result)){
$first_name=$array['firstName'];
$last_name=$array['lastName'];
$phone=$array['phone'];
$countryCode=$array['countryCode'];
$email=$array['email'];
$mobile=$array['mobile'];
$address=$array['address'];
$city=$array['city'];
$state=$array['state'];
$country=$array['country'];
$zipcode=$array['zipcode'];
}
}
if($Submit){
$firstName=$POST['firstName'];
$lastName=$POST['lastName'];
$phone=$POST['phone'];
$countryCode=$POST['countryCode'];
$email=$POST['email'];
$mobile=$POST['mobile'];
$address=$POST['address'];
$city=$POST['city'];
$state=$POST['state'];
$country=$POST['country'];
$zipcode=$_POST['zipcode'];
// Do update statement.
mysql_query("update generalcontact set name='$name', email='$email', tel='$tel' where name='$name' and pass='$pass'");
}
/$query="update from generalcontact
set (firstvName='$firstName', lastName='$lastName', email='$email', phone='$phone', mobile='$mobile', countryCode='$countryCode', address='$address', city='$city', state='$state', country='$country', zipCode='$zipCode')
where userID='$userID'";
$result=mysql_query($query,$connect);/
//$row=mysql_fetch_array($result);
mysql_close($connect);
?>
updateScript.php
<?php
// Connect database.
include("condb.php");
$table_name= 'generalcontact';
//$userID=$_SESSION['userID'];
//echo "userID=".$userID;
// ** This part will process when you Click on "Submit" button **
// Check, if you clicked "Submit" button
if($Submit){
$user_id=$POST['userID'];
$first_name=$POST['firstName'];
$last_name=$POST['lastName'];
$phone=$POST['phone'];
$countryCode=$POST['countryCode'];
$email=$POST['email'];
$mobile=$POST['mobile'];
$address=$POST['address'];
$city=$POST['city'];
$state=$POST['state'];
$country=$POST['country'];
$zipcode=$POST['zipcode'];
//session_register('userID');
}
// The id field is auto increment. You don't have to insert any value
// Do update statement.
/mysql_query("update generalcontact set firstName='$firstName', lastName='$lastName', phone='$phone', counrtyCode='$countryCode', email='$email', mobile='$mobile', address='$address', city='$city', state='$state', country='$country', zipcode='$zipcode where userID='$userID' and pass='$pass'");/
$query="update from generalcontact
set (firstName='$firstName', lastName='$lastName', email='$email', phone='$phone', mobile='$mobile', countryCode='$countryCode', address='$address', city='$city', state='$state', country='$country', zipcode='$zipcode')
where userID='$userID'";
$query="select * from generalcontact where userID='$userID'";
$result=mysql_query($query,$connect);
while($row=mysql_fetch_row($result)){
}
//$result=mysql_query($query,$connect);
//while($array=mysql_fetch_array($result)){
//foreach($array as $field){
/if($result){
if($array=mysql_fetch_array($result)){
$first_name=$array['firstName'];
$last_name=$array['lastName'];
$phone=$array['phone'];
$countryCode=$array['countryCode'];
$email=$array['email'];
$mobile=$array['mobile'];
$address=$array['address'];
$city=$array['city'];
$state=$array['state'];
$country=$array['country'];
$zipcode=$array['zipcode'];
}
}/
// Close database connection
mysql_close($connect);
?>