SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trouble updating field

    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 script Below.

    Code:
    <?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");
    ?>

  2. #2
    An average geek earl-grey's Avatar
    Join Date
    Mar 2005
    Location
    Ukraine
    Posts
    1,403
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Add print $user; statement before mysql_close().

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2005
    Location
    Nashville, TN
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Need to see your table structure, is the first record for this user... into the db?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •