Jump to content

Checking and Updating DB


jimmyp3016

Recommended Posts

I'm pretty sure it is

[code]Array ( [id] => 7 [userName] => testuser [firstName] => John [lastName] => Doe [address] => 56 happy rd [city] => Boston [state] => MA [zip] => 01915 [phone] => 333-333-3333 [company] => Google [website] => www.yahoo.com [aboutme] => a little about me [Submit] => Submit ) 2
Warning: Cannot modify header information - headers already sent by (output started at /home/content/p/o/w/powerpage/html/mem/signup.php:1) in /home/content/p/o/w/powerpage/html/mem/signup.php on line 39
[/code]

I kept the echo $numrows; on for this test
I am baffled as to why it isnt working...
Link to comment
Share on other sites

Just as a test... what does this produce?

[code]
<?php
$sql = "SELECT userName FROM user WHERE userName='$user'";
if ($result = mysql_query($sql,$db)) {
  if (mysql_num_rows($result) > 0) {
    while ($row = mysql_fetch_assoc($result)) {
      echo $row['userName']."<br />";
    }
  }
}
?>
[/code]
Link to comment
Share on other sites

Real wierd. remove the $db variable and try again.

[code]
<?php
$sql = "SELECT userName FROM user WHERE userName='$user'";
if ($result = mysql_query($sql)) {
  if (mysql_num_rows($result) > 0) {
    while ($row = mysql_fetch_assoc($result)) {
      echo $row['userName']."<br />";
    }
  }
}
?>
[/code]
Link to comment
Share on other sites

Your query has nothing to do with the address field. Are yo saying you initial issue was solved? How? Is this....

[code=php:0]
$sql = "SELECT userName FROM user WHERE userName='$user'";
if ($result = mysql_query($sql,$db)) {
  if (mysql_num_rows($result) > 0) {
    header("Location: error2.html");
    exit;
  }
}
[/code]

working for you now?
Link to comment
Share on other sites

So I jumped the gun and thought it was solved after I changed the address field. When i submit I get this error

Warning: Cannot modify header information - headers already sent by (output started at /home/content/p/o/w/powerpage/html/mem/signup.php:3) in /home/content/p/o/w/powerpage/html/mem/signup.php on line 46

Line 46 is the error2.html header so nothing is getting updated to the db
Link to comment
Share on other sites

Ok here is the current working code. This code works perfect and goes to the next page and also updates the users fields.

The field that it does not update is the userName field! Haha The one I actually need!

The funny thing is that it sends out a mail to myself one someone signs up and it includes the username in it! It sent the username in the email! Its just not updating on the table!

What is happening!

BTW...You guys/girls are the best!

[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");
?>
[/code]
Link to comment
Share on other sites

[quote]The funny thing is that it sends out a mail to myself one someone signs up and it includes the username in it![/quote]

How? Where do you define $mailbody?

Also, are you aware that variables do NOT need to be surrounded by quotes?

If your not getting the mysql_error() as defined within the die() then your query is fine. If userName is not being updated then $user is empty. However this would normally trigger an error unless your userName field allows nulls.
Link to comment
Share on other sites

[quote author=thorpe link=topic=121872.msg501977#msg501977 date=1168488981]

How? Where do you define $mailbody?

[color=red]In the include 'corpmessage.php'; line[/color]

Also, are you aware that variables do NOT need to be surrounded by quotes?

[color=red]Im still pretty new to php so I dont know exact syntax[/color]

If your not getting the mysql_error() as defined within the die() then your query is fine. If userName is not being updated then $user is empty. However this would normally trigger an error unless your userName field allows nulls.

[color=red]Should I set the userName field to Null?[/color]
[/quote]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.