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
https://forums.phpfreaks.com/topic/102348-solved-variable-question/
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.

 

<?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 />"; 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.