Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,217 members, 7,818,735 topics. Date: Sunday, 05 May 2024 at 11:29 PM

Is Something Wrong With This Code - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Is Something Wrong With This Code (1881 Views)

5,000 Naira For Someone Who Can Reverse This Code / Python Experts, Plz What Is Wrong With This Code / Need Help With This Code (2) (3) (4)

(1) (Reply) (Go Down)

Is Something Wrong With This Code by 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','username','password');
$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>&nbsp;</td>
<td>&nbsp;</td>
<td height="67">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" align="center" bgcolor="#FFFFFF">
<img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p>&nbsp;</p>
<p><font face="Bodoni MT"><b>The &quot;<font color="#FF0000">NAME</font>&quot; Field is empty</b></font></p>
<p><a href="javascript:history.back(-1);">Back</a></p>
<p></td>
<td height="350">&nbsp;</td>
</tr>
<tr>
<td width="143">&nbsp;</td>
<td width="476">&nbsp;</td>
<td height="72" width="160">&nbsp;</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>&nbsp;</td>
<td>&nbsp;</td>
<td height="67">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" align="center" bgcolor="#FFFFFF">
<img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p>&nbsp;</p>
<p><font face="Bodoni MT"><b>The &quot;<font color="#FF0000">ADDRESS</font>&quot; Field is empty</b></font></p>
<p><a href="javascript:history.back(-1);">Back</a></p>
<p></td>
<td height="350">&nbsp;</td>
</tr>
<tr>
<td width="143">&nbsp;</td>
<td width="476">&nbsp;</td>
<td height="72" width="160">&nbsp;</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>&nbsp;</td>
<td>&nbsp;</td>
<td height="67">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" align="center" bgcolor="#FFFFFF">
<img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p>&nbsp;</p>
<p><font face="Bodoni MT"><b>The &quot;<font color="#FF0000">EMAIL</font>&quot; Field is empty</b></font></p>
<p><a href="javascript:history.back(-1);">Back</a></p>
<p></td>
<td height="350">&nbsp;</td>
</tr>
<tr>
<td width="143">&nbsp;</td>
<td width="476">&nbsp;</td>
<td height="72" width="160">&nbsp;</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>&nbsp;</td>
<td>&nbsp;</td>
<td height="67">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" align="center" bgcolor="#FFFFFF">
<img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p>&nbsp;</p>
<p><font face="Bradley Hand ITC"><b>Your &quot;<font color="#FF0000">EMAIL</font>&quot;
</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">&nbsp;</td>
</tr>
<tr>
<td width="143">&nbsp;</td>
<td width="476">&nbsp;</td>
<td height="72" width="160">&nbsp;</td>
</tr>
</table></div>

<?
}

// THIS IS WHERE I CHECKED FOR MULTIPLE ENTRIES

elseif($email=="$p[mail]"wink
{
?>
<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>&nbsp;</td>
<td>&nbsp;</td>
<td height="67">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" align="center" bgcolor="#FFFFFF">
<img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p>&nbsp;</p>
<p><b><font face="Bodoni MT">You have been previously
registered for <font size="5">BFS</font></font></b></p>
<p><a href="javascript:history.back(-1);">Back</a></p>
<p></td>
<td height="350">&nbsp;</td>
</tr>
<tr>
<td width="143">&nbsp;</td>
<td width="476">&nbsp;</td>
<td height="72" width="160">&nbsp;</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>&nbsp;</td>
<td>&nbsp;</td>
<td height="67">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" align="center" bgcolor="#FFFFFF">
<img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p>&nbsp;</p>
<p><font face="Bodoni MT"><b>The &quot;<font color="#FF0000">PHONE</font>&quot;
field must not be empty</b></font></p>
<p><a href="javascript:history.back(-1);">Back</a></p>
<p></td>
<td height="350">&nbsp;</td>
</tr>
<tr>
<td width="143">&nbsp;</td>
<td width="476">&nbsp;</td>
<td height="72" width="160">&nbsp;</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>&nbsp;</td>
<td>&nbsp;</td>
<td height="67">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" align="center" bgcolor="#FFFFFF">
<img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p>&nbsp;</p>
<p><font face="Bodoni MT"><b>The &quot;<font color="#FF0000">PHONE</font>&quot;
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">&nbsp;</td>
</tr>
<tr>
<td width="143">&nbsp;</td>
<td width="476">&nbsp;</td>
<td height="72" width="160">&nbsp;</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>&nbsp;</td>
<td>&nbsp;</td>
<td height="67">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" align="center" bgcolor="#FFFFFF">
<img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p>&nbsp;</p>
<p>&nbsp;</p>
<p><b><font face="Bodoni MT">You have been successfully registered
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">&nbsp;</td>
</tr>
<tr>
<td width="143">&nbsp;</td>
<td width="476">&nbsp;</td>
<td height="72" width="160">&nbsp;</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>&nbsp;</td>
<td>&nbsp;</td>
<td height="67">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td valign="top" align="center" bgcolor="#FFFFFF">
<img border="0" src="images/stories/bfs_form_header.jpg" width="439" height="119"><p>&nbsp;</p>
<p>&nbsp;</p>
<p><b><font face="Bodoni MT" color="#FF0000">An error occured while
trying to register 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">&nbsp;</td>
</tr>
<tr>
<td width="143">&nbsp;</td>
<td width="476">&nbsp;</td>
<td height="72" width="160">&nbsp;</td>
</tr>
</table></div>


<?
}
}
}
?>
Re: Is Something Wrong With This Code by lordZOUGA(m): 8:10pm On Sep 14, 2012
ask your debugger
Re: Is Something Wrong With This Code by Kslib(m): 8:23pm On Sep 14, 2012
lordZOUGA: ask your debugger
Am not a programmer,but wasn't the debugger created by someone...
Re: Is Something Wrong With This Code by Javanian: 8:28pm On Sep 14, 2012
lol grin
Re: Is Something Wrong With This Code by lordZOUGA(m): 10:05pm On Sep 14, 2012
Kslib:
Am not a programmer,but wasn't the debugger created by someone...
you are definitely not a programmer
Re: Is Something Wrong With This Code by Kslib(m): 10:10pm On Sep 14, 2012
lordZOUGA: @kslib
you really got me
Re: Is Something Wrong With This Code by Kslib(m): 10:11pm On Sep 14, 2012
Now watch me program ur comments...
lordZOUGA: @kslib
you really got me
i told ya!!!
Re: Is Something Wrong With This Code by 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";
Re: Is Something Wrong With This Code by 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
Re: Is Something Wrong With This Code by 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 user to get a life
if it doesn't, insert it.

(1) (Reply)

What App/Startup Clones Would Be Successful In Nigeria Or Africa? / Creating A New Programming Language / More Than 750,000 Lenovo Laptops Have Spy Ware Pre-installed In Them

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 62
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.