felipeebs Posted August 9, 2007 Share Posted August 9, 2007 Helo! I'm developing a simple e-mail database, where the users can register their and receive som news posted by another script. My script runs perfectlly over php 4 but when I try it on a PHP 5 server (testing in WAMP5) it just don't work! It ignores the ifs and elseifs than returns: "Error 003 unable to save data!"); echo "E-mail is now registered!"; } } else { echo "Invalid e-mail adress!"; } ?>" Here is the full code for insert.php: <? include("inc/db_config.php"); $nome = $_GET['nome']; $email = $_GET['email']; $normal = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$"; if ($nome == "") { echo "Please type your <b>name</b>. "; } elseif ($email == "") { echo "Please type your <b>e-mail</b>. "; } elseif (eregi($normal, $email) && $nome !="") { $check = "SELECT email FROM `newsletter` WHERE `email`='".$email."'"; $verif = mysql_query($check); if (mysql_num_rows($verif) != 0) { die("E-mail already registered!"); } else { $sql = "INSERT INTO `newsletter` VALUES (NULL,'$nome','$email')"; $query = mysql_query($sql) or die ("<b>Error 003</b> unable to save data!"); echo "E-mail is now registered!"; } } else { echo "Invalid <b>e-mail adress</b>!"; } ?> What am I doing wrng? I hope someone can help me. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/64161-solved-php-5-ignoring-the-if/ Share on other sites More sharing options...
SirChick Posted August 9, 2007 Share Posted August 9, 2007 u should use $_POST for registration .. ideally... change your form to $_POST .and change those $_GETS to $_POST this wont fix the problem but its a better method.... Quote Link to comment https://forums.phpfreaks.com/topic/64161-solved-php-5-ignoring-the-if/#findComment-319758 Share on other sites More sharing options...
Fadion Posted August 9, 2007 Share Posted August 9, 2007 Dont know whats going wrong with your script but im just pointing two things that can make your code a bit easier to write and read. In queries u dont need apostrophes, it will work even without those. "INSERT INTO `newsletter` VALUES (NULL,'$nome','$email')" And also in queries, variables can be called inside double quotes: "SELECT email FROM `newsletter` WHERE `email`='".$email."'"; to "SELECT email FROM newsletter WHERE email='$email'"; Quote Link to comment https://forums.phpfreaks.com/topic/64161-solved-php-5-ignoring-the-if/#findComment-319764 Share on other sites More sharing options...
SirChick Posted August 9, 2007 Share Posted August 9, 2007 you should keep it consistent aswell... firstly you use "if and elseif" but then you use "if and else" change those "else" to elseif Quote Link to comment https://forums.phpfreaks.com/topic/64161-solved-php-5-ignoring-the-if/#findComment-319803 Share on other sites More sharing options...
rlindauer Posted August 10, 2007 Share Posted August 10, 2007 Are shorttags enabled for php5? I thought they were off by default, so you have to actually use <?php and not just <? Quote Link to comment https://forums.phpfreaks.com/topic/64161-solved-php-5-ignoring-the-if/#findComment-319890 Share on other sites More sharing options...
felipeebs Posted August 10, 2007 Author Share Posted August 10, 2007 Are shorttags enabled for php5? I thought they were off by default, so you have to actually use <?php and not just <? Oh mother! how couldn't I see this be4? dang! (sorry bout the fool words) Thank you infinitelly very much for opening my "eye" From now I will never forget to start with "<?php" instead of just "<?"! The topic is now solved! Quote Link to comment https://forums.phpfreaks.com/topic/64161-solved-php-5-ignoring-the-if/#findComment-319949 Share on other sites More sharing options...
rlindauer Posted August 10, 2007 Share Posted August 10, 2007 I can't tell if you are being sarcastic or not, so, uh, thanks? Quote Link to comment https://forums.phpfreaks.com/topic/64161-solved-php-5-ignoring-the-if/#findComment-320502 Share on other sites More sharing options...
felipeebs Posted August 10, 2007 Author Share Posted August 10, 2007 I can't tell if you are being sarcastic or not, so, uh, thanks? no, not sarcastic just happy I didn't know that the "short open tag" was disabled... and instead of enabling it, corrected the code and... duh... thanks Quote Link to comment https://forums.phpfreaks.com/topic/64161-solved-php-5-ignoring-the-if/#findComment-320511 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.