Jump to content

Recommended Posts

alright chaps....

 

at the moment, if I run this on my page

 

$test = mysql_real_escape_string($_POST['FOOTBALL']);
$name = 'Jerry Hughes';

$sql = "UPDATE upc
SET FOOTBALL='$test'
WHERE Name = '$name'";

$updateresult = mysql_query($sql) or die(mysql_error()); 

echo 'Picks Complete';

 

I get the result of my Select field which is named Football put into the row in my database which is Jerry Hughes.

 

BUT, What I've got is more than one username in the database, about 50 different people in fact, So I want to be able to replace the $name with the name of the person who is logged in.

 

On the page I've got a session running, as they have to log in to get to this page.

 

For instance, when they log in, I run Hi <?=$_SESSION['name']?>  which says Hi Jerry Hughes as the name I've logged in with is Jerry Hughes.

 

How do I go incorporating this into my UPDATE query above, so it takes the name of who's logged in and inserts the FOOTBALL thing into their row in the database?

 

Any help makes me a very happy chappy!

$test = mysql_real_escape_string($_POST['FOOTBALL']);
$name = $_SESSION['name'];

$sql = "UPDATE upc
SET FOOTBALL='$test'
WHERE Name = '$name'";

$updateresult = mysql_query($sql) or die(mysql_error()); 

echo 'Picks Complete';

 

note that you will need to declare session_start at the beginning of your script

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.