Current location: Hot Scripts Forums » Programming Languages » PHP » Compare and update


Compare and update

Reply
  #1 (permalink)  
Old 10-26-03, 09:03 AM
perleo perleo is offline
Coding Addict
 
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
Compare and update

Hi, iam trying to take the two values of 2 input fields, compare them and if they are the same update the db, but it doesnt work, can someone fix this please
PHP Code:

<?php

/* Admin area for aircraft
Version 1.0
-colinok
*/
session_start();

  
// check session variable

  
if (isset($HTTP_SESSION_VARS['valid_user']))
//WORK WITHIN THE SESSION


include('../dbconnect.php');

$conn db_connect();

  
$mail1 $HTTP_POST_VARS['mail1'];
  
$mail2 $HTTP_POST_VARS['mail2'];
  
if (
$mail1 === $mail2)
// CHANGE EMAIL SECTION START
 
echo 'E-Mails are the same';
 
$mail1 addslashes($mail1);
 
$mail2 addslashes($mail2);
 
$query =("UPDATE pilots set email = '$mail1' where user = '$userid'");
        
//CHANGE EMAIL SECTION END
  //IF EMAILS ARE DIFFERENT TELL THEM
else {
echo 
'E-Mails are NOT the same';
      }
// IF NOT LOGGED IN TELL THEM 
// 
else
  {
    echo 
'<p>You are not logged in.</p>';
    echo 
'<p>Only logged in members may see this page.</p>';
  }
?>
the $userid is the user logged in. So if the 2 input fields are the same, update the column email where the user is $userid, does the user column have to be a primary key, also the user column is the second column, would that cause a problem?
Reply With Quote
  #2 (permalink)  
Old 10-27-03, 03:00 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
in your code you wrote:
PHP Code:

$query =("UPDATE pilots set email = '$mail1' where user = '$userid'"); 

but I can't find any variable labeled $userid in your script

also what exactly appear after you pass the 2 variables to this script ?
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 10-27-03, 03:53 AM
perleo perleo is offline
Coding Addict
 
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
$userid was pre declared when you log in,

I get E-Mails are the same, which they are not, because i put in different emails in the two inputs
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 07:16 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.