Hey Guys/Girls
Im having a problem with my script. It works perfectly and redirects to the next page but it updates all of the fields in the db except the userName field.
This is the field that im most concerned about because it has to be unique.
The funny thing is that the script also sends me an email from (include corpmessage.php) and it has the username in the email!!
So i know it is grabing the variable but I dont know why it is not updating on the table.
Any ideas? Maybe its because im checking to see if the same username exsists first? My database setup?
My script Below.
<?php
$userID = $_REQUEST['id'];
$user = $_GET['userName'];
$firstname = $_GET['firstName'];
$lastname = $_GET['lastName'];
$address = $_GET['address1'];
$city = $_GET['city'];
$state = $_GET['state'];
$zip = $_GET['zip'];
$phone = $_GET['phone'];
$company = $_GET['company'];
$website = $_GET['website'];
$aboutme = $_GET['aboutme'];
if ( ($user=="") || ($firstname=="") || ($lastname=="") || ($phone=="") || ($company=="") || ($website=="") )
{
header("Location:error1.html");
exit;
}
include "../config-site.php";
include 'corpmessage.php';
// Open database...
$db = mysql_connect("$localhost", "$databaseuser", "$databasepasswd");
mysql_select_db("$databasename",$db);
$sql="SELECT userName FROM user WHERE userName='$user'";
$result = mysql_query("$sql",$db);
if (mysql_num_rows($result) != 0) {
header("Location:error2.html");
exit;
}
$sql = "SELECT * FROM user WHERE id='$userID'";
$sql = "UPDATE user SET firstName = '$firstname', lastName = '$lastname', address1 = '$address', city = '$city', state = '$state', zip = '$zip', userName = '$user', phone = '$phone', company = '$company', website = '$website', aboutme = '$aboutme' WHERE id='$userID'";
$result = mysql_query($sql,$db) || die("Can't query DB: ". mysql_error());
// Close database...
mysql_close($db);
// Send message to inform webmaster about the new affiliate...
$subject="$firstname $lastname has signed up with $sitename";
mail("$affiliaterecipient","$subject","$mailbody","From: $siteemail \nContent-Type: text/plain; charset=iso-8859-1\nContent-Transfer-Encoding: 8bit");
// Show thank you message...
header("Location:invite.php?id=$userID");
?>