Jump to content

[SOLVED] Variable Question


Clinton

Recommended Posts

Here's the code that I am using to basically verifiy someone's information and change stuff in the database. There is a double verification part that selects * from the database. How can I extract that information, and put it into variables? (In my DB I have first, middle, and last. How do I extract that and put into first = $first format?)

 


$id = $_REQUEST['id'];
$code = $_REQUEST['code'];
$sql = mysql_query("UPDATE usert SET activated='1' WHERE id='$id' AND password='$code'");
$sql_doublecheck = mysql_query("SELECT * FROM usert WHERE id='$id' AND password='$code' AND activated='1'");
$doublecheck = mysql_num_rows($sql_doublecheck);
if($doublecheck == 0){
echo "<strong><font color=red>Your account could not be verified! Please contact the Administrator.</font></strong>";
} elseif ($doublecheck > 0) {
echo "<strong>Your e-mail address has been verified!</strong> Your will be contact shortly by the administrator for account activation.<br />"; 

Link to comment
Share on other sites

Either do something like:

 

$row = mysql_fetch_assoc($sql_doublecheck);
$first = $row['first'];

 

Or:

 

extract(mysql_fetch_assoc($sql_doublecheck));
echo $first;//assuming your field is called first

 

See the manual for what happens when you use extract and there is already a variable with the field name.

 

Link to comment
Share on other sites

<?php
session_start();
$_SESSION['last_querry'] = 0;

$id = $_REQUEST['id'];
$code = $_REQUEST['code'];
$sql = mysql_query("UPDATE usert SET activated='1' WHERE id='$id' AND password='$code'");
$sql_doublecheck = mysql_query("SELECT * FROM usert WHERE id='$id' AND password='$code' AND activated='1'");
$row = mysql_fetch_assoc($sql_doublecheck);
$firstname = $row['first'];
$middle = $row['middle'];
$last = $row['last'];
$doublecheck = mysql_num_rows($sql_doublecheck);
if($doublecheck == 0){
echo "<strong><font color=red>Your account could not be verified! Please contact the Administrator.</font></strong>";
} elseif ($doublecheck > 0) {
echo "<strong>Your e-mail address has been verified!</strong> Your will be contact shortly by the administrator for account activation.<br />"; 

Link to comment
Share on other sites

Thanks for the help folks.

 

The only reason I'm using request is because the individual was mailed a link to basically verify their address. The only way to do pass the information via link is REQUEST. It's the only time that I use it.

Link to comment
Share on other sites

Thanks for the help folks.

 

The only reason I'm using request is because the individual was mailed a link to basically verify their address. The only way to do pass the information via link is REQUEST. It's the only time that I use it.

 

Use $_GET.  $_REQUEST is a combination of Get, Post, and Cookie, so it's not too safe.

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.