PHP Still inserts data even if the condition is not met (IE)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
php_ghost
Forum Commoner
Posts: 55
Joined: Thu Jan 11, 2007 3:29 am

PHP Still inserts data even if the condition is not met (IE)

Post by php_ghost »

Hi guys i'm having this weird problem in php / IE. I have a page with a form and text boxes and when I click the submit button, It will be posted to a second php page which contains this code.
It all works fine in firefox however.
What could possibly be wrong with my code? Please help me guys. I've been stuck in the office trying to figure this one out.
Thanks. ^_^

Code: Select all

<?
require_once("../../common/include.php")
include_once("../../lib/functions.lib.php")
include_once("postVar.php");

$query = "SELECT * from $default_table_accounts WHERE loginemail='$loginemail'";
$result = db_query($query) or die(db_error());

if(db_num_rows($result)) {
include_once("hiddenFields.php");
-- go back to previous page --
} else {

$password = generate_password();
$refcode = generate_refcode();
$applicationdate = date("Y-m-d H:i:s");

$querystr  = "INSERT INTO $default_table_accounts (professionalcapacity,operationarea,country,desiredstartingdate,desiredsalary,firstname,
middlename,lastname,gender,birthdate,maritalstatus,nationality,phonenum,username,loginemail,password,address,zipcode,city,homecountry,applicationdate,regstatus,refcode) VALUES ";
$querystr .= "('$professionalcapacity','$operationarea','$country','$desiredstartingdate','$desiredsalary','$firstname'
,'$middlename','$lastname','$gender','$birthdate','$maritalstatus','$nationality','$phonenum','$loginemail','$loginemail','$password','$address','$zipcode','$city','$homecountry','$applicationdate','I','$refcode')";
$querystr .= db_query($querystr) or die(db_error()); 
 
 
}
?>
Last edited by php_ghost on Thu Jan 11, 2007 4:17 am, edited 1 time in total.
GM
Forum Contributor
Posts: 365
Joined: Wed Apr 26, 2006 4:19 am
Location: Italy

Post by GM »

Why are you using PHP tags on every line of code?????

Code: Select all

<?php
   //all you code ;
   // goes here ;
   //on various lines ;
   // ended with semicolons ;
   // and then, at the end ;
   // you close the php tag ;
?>
The problem is probably on the page with your form on it rather thean the page which inserts the data.
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

check the db_num_rows($result) value.
php_ghost
Forum Commoner
Posts: 55
Joined: Thu Jan 11, 2007 3:29 am

Post by php_ghost »

but it all works fine in firefox.

What it does when I'm in IE is it executes the data insertion first before reading the if / else statement.

But when I just use echo for both conditions it works fine.
GM
Forum Contributor
Posts: 365
Joined: Wed Apr 26, 2006 4:19 am
Location: Italy

Post by GM »

PHP doesn't care much about what browser you use - it runs on the server, and so is oblivious to the browser. This means that if for some reason you are getting different results with different browsers, it generally means that you have a problem in your HTML or javascript on the calling page.

I'd check what's going on in your hiddenfields.php include for starters.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

print and check the query

Code: Select all

$query = "SELECT * FROM $default_table_accounts WHERE loginemail='$loginemail'";
echo '<div>Debug: ', $query, "</div>";
$result = db_query($query) or die(db_error());
Post Reply