Clinton Posted April 22, 2008 Share Posted April 22, 2008 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 />"; Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted April 22, 2008 Share Posted April 22, 2008 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. Quote Link to comment Share on other sites More sharing options...
jonsjava Posted April 22, 2008 Share Posted April 22, 2008 <?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 />"; Quote Link to comment Share on other sites More sharing options...
947740 Posted April 22, 2008 Share Posted April 22, 2008 If you have multiple rows of data you want, you can do this: while($row = mysqli_fetch_row($doublecheck)) { // Code goes here that processes information } Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 22, 2008 Share Posted April 22, 2008 Never use $_REQUEST. Just don't. =( Quote Link to comment Share on other sites More sharing options...
Clinton Posted April 22, 2008 Author Share Posted April 22, 2008 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. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 22, 2008 Share Posted April 22, 2008 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. Quote Link to comment Share on other sites More sharing options...
Clinton Posted April 22, 2008 Author Share Posted April 22, 2008 Ok. Didn't know that. Thank you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.