NewStats: 3,264,924 , 8,185,100 topics. Date: Thursday, 12 June 2025 at 07:45 PM 4q1v2d6z3e3g |
Is Something Wrong With This Code (1953 Views)
(1) (Go Down)
ebenz01: 1:02pm On Sep 14, 2012 |
Pls is something wrong with my code? im trying to avoid multiple email entries, but the code keeps inserting data with multiple emails. And whenever i put email as unique in my database, it dosent show anything if the data already exist <? if($submit) { $name=$_POST[name]; $address=$_POST[address]; $email=$_POST[email]; $phone=$_POST[phone]; $conn=mysql_connect('localhost','name',''); $db=mysql_select_db('family_jo151'); $query1="SELECT * FROM bfs_list WHERE email='.mysql_real_escape_string($_POST[email]) .'"; $result=mysql_query($query1)or die(mysql_error()); $p=mysql_fetch_array($result); if(empty($name)) { ?> <div align="center"> <p></div> <div align="center"> <table cellpadding="0" cellspacing="0" width="779" height="489" background="images/stories/bfs_form_bg.jpg"> <!-- MSTableType="layout" --><tr> <td> </td> <td> </td> <td height="67"> </td> </tr> <tr> <td> </td> <td valign="top" align="center" bgcolor="#FFFFFF"> <img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p> </p> <p><font face="Bodoni MT"><b>The "<font color="#FF0000">NAME</font>" Field is empty</b></font></p> <p><a href="javascript:history.back(-1);">Back</a></p> <p></td> <td height="350"> </td> </tr> <tr> <td width="143"> </td> <td width="476"> </td> <td height="72" width="160"> </td> </tr> </table></div> <? } elseif(empty($address)) { ?> <div align="center"> <p></div> <div align="center"> <table cellpadding="0" cellspacing="0" width="779" height="489" background="family%20booster/bfs_form_bg.jpg"> <!-- MSTableType="layout" --><tr> <td> </td> <td> </td> <td height="67"> </td> </tr> <tr> <td> </td> <td valign="top" align="center" bgcolor="#FFFFFF"> <img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p> </p> <p><font face="Bodoni MT"><b>The "<font color="#FF0000">ADDRESS</font>" Field is empty</b></font></p> <p><a href="javascript:history.back(-1);">Back</a></p> <p></td> <td height="350"> </td> </tr> <tr> <td width="143"> </td> <td width="476"> </td> <td height="72" width="160"> </td> </tr> </table></div> <? } elseif(empty($email)) { ?> <div align="center"> <p></div> <div align="center"> <table cellpadding="0" cellspacing="0" width="779" height="489" background="images/stories/bfs_form_bg.jpg"> <!-- MSTableType="layout" --><tr> <td> </td> <td> </td> <td height="67"> </td> </tr> <tr> <td> </td> <td valign="top" align="center" bgcolor="#FFFFFF"> <img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p> </p> <p><font face="Bodoni MT"><b>The "<font color="#FF0000">EMAIL</font>" Field is empty</b></font></p> <p><a href="javascript:history.back(-1);">Back</a></p> <p></td> <td height="350"> </td> </tr> <tr> <td width="143"> </td> <td width="476"> </td> <td height="72" width="160"> </td> </tr> </table></div> <? } elseif (!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})$", $email)) { ?> <div align="center"> <p></div> <div align="center"> <table cellpadding="0" cellspacing="0" width="779" height="489" background="images/stories/bfs_form_bg.jpg"> <!-- MSTableType="layout" --><tr> <td> </td> <td> </td> <td height="67"> </td> </tr> <tr> <td> </td> <td valign="top" align="center" bgcolor="#FFFFFF"> <img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p> </p> <p><font face="Bradley Hand ITC"><b>Your "<font color="#FF0000">EMAIL</font>" </b></font><b><font face="Bodoni MT">is not in the correct format</font></b></p> <p><a href="javascript:history.back(-1);">Back</a></p> <p></td> <td height="350"> </td> </tr> <tr> <td width="143"> </td> <td width="476"> </td> <td height="72" width="160"> </td> </tr> </table></div> <? } // THIS IS WHERE I CHECKED FOR MULTIPLE ENTRIES elseif($email=="$p[mail]" ![]() { ?> <div align="center"> <p></div> <div align="center"> <table cellpadding="0" cellspacing="0" width="779" height="489" background="images/stories/bfs_form_bg.jpg"> <!-- MSTableType="layout" --><tr> <td> </td> <td> </td> <td height="67"> </td> </tr> <tr> <td> </td> <td valign="top" align="center" bgcolor="#FFFFFF"> <img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p> </p> <p><b><font face="Bodoni MT">You have been previously ed for <font size="5">BFS</font></font></b></p> <p><a href="javascript:history.back(-1);">Back</a></p> <p></td> <td height="350"> </td> </tr> <tr> <td width="143"> </td> <td width="476"> </td> <td height="72" width="160"> </td> </tr> </table></div> <? } elseif(empty($phone)) { ?> <div align="center"> <table cellpadding="0" cellspacing="0" width="779" height="489" background="images/stories/bfs_form_bg.jpg"> <!-- MSTableType="layout" --><tr> <td> </td> <td> </td> <td height="67"> </td> </tr> <tr> <td> </td> <td valign="top" align="center" bgcolor="#FFFFFF"> <img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p> </p> <p><font face="Bodoni MT"><b>The "<font color="#FF0000">PHONE</font>" field must not be empty</b></font></p> <p><a href="javascript:history.back(-1);">Back</a></p> <p></td> <td height="350"> </td> </tr> <tr> <td width="143"> </td> <td width="476"> </td> <td height="72" width="160"> </td> </tr> </table></div> <? } elseif(!ereg("^([0-9]{9,13})$", $phone)) { ?> <div align="center"> <table cellpadding="0" cellspacing="0" width="779" height="489" background="images/stories/bfs_form_bg.jpg"> <!-- MSTableType="layout" --><tr> <td> </td> <td> </td> <td height="67"> </td> </tr> <tr> <td> </td> <td valign="top" align="center" bgcolor="#FFFFFF"> <img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p> </p> <p><font face="Bodoni MT"><b>The "<font color="#FF0000">PHONE</font>" field value must contain numbers only, and minimum of 9 numbers, maximum of 13 numbers</b></font></p> <p><a href="javascript:history.back(-1);">Back</a></p> <p></td> <td height="350"> </td> </tr> <tr> <td width="143"> </td> <td width="476"> </td> <td height="72" width="160"> </td> </tr> </table></div> <? } else { $query="INSERT INTO bfs_list VALUES ('$name','$address','$email','$phone','')"; $suxes=mysql_query($query); if($suxes) { ?> <div align="center"> <table cellpadding="0" cellspacing="0" width="779" height="489" background="images/stories/bfs_form_bg.jpg"> <!-- MSTableType="layout" --><tr> <td> </td> <td> </td> <td height="67"> </td> </tr> <tr> <td> </td> <td valign="top" align="center" bgcolor="#FFFFFF"> <img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p> </p> <p> </p> <p><b><font face="Bodoni MT">You have been successfully ed for BFS Summit</font></b></p> <p><b><font face="Bodoni MT"><a href="http://familybooster.com"> Click Here</a> to Continue</font></b></td> <td height="350"> </td> </tr> <tr> <td width="143"> </td> <td width="476"> </td> <td height="72" width="160"> </td> </tr> </table></div> <? } else { ?> <div align="center"> <table cellpadding="0" cellspacing="0" width="779" height="489" background="images/stories/bfs_form_bg.jpg"> <!-- MSTableType="layout" --><tr> <td> </td> <td> </td> <td height="67"> </td> </tr> <tr> <td> </td> <td valign="top" align="center" bgcolor="#FFFFFF"> <img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p> </p> <p> </p> <p><b><font face="Bodoni MT" color="#FF0000">An error occured while trying to you</font></b></p> <p><b><font face="Bodoni MT"><a href="javascript:history.back(-1);"> Click Here</a> to try again</font></b></p> </td> <td height="350"> </td> </tr> <tr> <td width="143"> </td> <td width="476"> </td> <td height="72" width="160"> </td> </tr> </table></div> <? } } } ?> |
lordZOUGA(m): 8:10pm On Sep 14, 2012 |
ask your debugger
|
Kslib(m): 8:23pm On Sep 14, 2012 |
lordZOUGA: ask your debuggerAm not a programmer,but wasn't the debugger created by someone... |
Javanian: 8:28pm On Sep 14, 2012 |
lol ![]() |
lordZOUGA(m): 10:05pm On Sep 14, 2012 |
Kslib:you are definitely not a programmer |
Kslib(m): 10:10pm On Sep 14, 2012 |
lordZOUGA: @kslib |
Kslib(m): 10:11pm On Sep 14, 2012 |
Now watch me program ur comments...
lordZOUGA: @kslibi told ya!!! |
VictorAkujobi: 7:49pm On Sep 16, 2012 |
Do you have "on duplicate" in your query? If you make the fields unique, you need to add in "<initial query>on duplicate $this = $that, $thisOtherThing = $thatOtherThing";
|
VictorAkujobi: 8:07pm On Sep 16, 2012 |
Oh and escape the variables in your query or better yet, use mysqli with prepared statements or even better yet, PDO. You don't want someone stealing your data, or worse, dropping your DB tables
|
ebenz01: 8:28am On Sep 26, 2012 |
tnks for ur contribution. I finally got a way round it
|
Re: Is Something Wrong With This Code by Nobody: 8:32am On Oct 04, 2012 |
I THINK YOU SHOULD GO TO YOUR DATABASE BACKEND AND TWEEK THE EMAIL TABLE TO UNIQUE,OR BETTER STILL CREATE A QUERY THAT CHECK AND REPLY EXISTING EMAIL.
|
Re: Is Something Wrong With This Code by Nobody: 9:04am On Oct 04, 2012 |
build a logic to check the database if email exists, if it exists, tell the to get a life if it doesn't, insert it. |
(1) (Reply)
How To Earn $100 Per Day By ob Booster From Google ob ?
(Go Up)
Sections: How To . 46 Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or s on Nairaland. |