homepage Welcome to WebmasterWorld Guest from 54.211.97.242
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
php and mysql database search! need help please!
mysql php problem case sensitivity
onawire



 
Msg#: 4173832 posted 6:03 am on Jul 21, 2010 (gmt 0)

I run a contest from my website where ppl fill out an html form to enter.

Required info: fname, lname, phone, location, email, etc..

I wanted to be able to control how many times per day a person can enter the contest (I want it to be ONCE per day!)

Seemed easy enough, for someone that has expert knowledge (aka...not me!)

so i've been searching the ENTIRE internet for ways to do this! cookies, cgi, mysql, php, javascript forums everything! did i mention i'm new to anything more complicated than html and css.

First:

when my form is submitted - it calls action="file.php"
the php file is set to do a serverside validation.
then, contact mysql database and put all the info into a table.
then, it sends me an email with some info and to let me know someone has entered.

worked perfect!

then, my contests started getting bigger and i wanted to control how many entries per day a person could send.

so, i thought, ppl have a unique email address that i can use as my control

so, when a person tries to enter and puts an email into the html form...my php file contacts my database and searchs for that email they just entered. if the email isn't in the table at all, it lets it go thru.

i also have it look at the date of the entries via that email address, if the email address is found and the date matches the current date. bam...no entry and i redirect them to a sorry you can't enter again today html page.

EVERYTHING works awesome...except ONE thing!

case sensitivity of the email address!

i tested this and i just changed one letter to upper case...and...

it went thru...it saw it as a different email address.

can someone help me!

ps. sorry for the long drawn out message! if i knew how to speak in technical terms i would..i just wanted to fully explain everything

(also, i am aware of the most obvious problem! - fake email addresses - one thing at a time)

here is a copy of my php file that my html form calls.


<?php

if(!isset($_POST['submit']))
{
//This page should not be accessed directly. Need to submit the form.
echo "ERROR: You need to submit the form - You do not have permission from WBSnightout.com to see this page!";
exit;
}

//Set variables
$FNAME = $_POST['FNAME'];
$LNAME = $_POST['LNAME'];
$LOCATION = $_POST['LOCATION'];
$PHONE = $_POST['PHONE'];
$EMAIL = $_POST['EMAIL'];
$TRACKING = $_POST['TRACKING'];
$NEWSLETTER = $_POST['NEWSLETTER'];
$ANSWER = $_POST['ANSWER'];
$CONTEST = $_POST['CONTEST'];
$HELPFUL = $_POST['HELPFUL'];
$COMMENTS = $_POST['COMMENTS'];
$TERMS = $_POST['terms'];
$nowdate = date("Y-m-d");


//Validate first
if(empty($FNAME)||empty($LNAME))
{
echo "Full Name is Manditory!";
exit;
}

if(empty($LOCATION))
{
echo "Location is Manditory!";
exit;
}

if(empty($PHONE))
{
echo "Phone Number is Manditory!";
exit;
}

if(empty($TRACKING))
{
echo "Phone Number is Manditory!";
exit;
}

if(empty($EMAIL))
{
echo "Email is Manditory!";
exit;
}

//make connection
mysql_connect ("localhost", "username", "pword") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("sql_db");

// Get a specific result from the database_table
$result = mysql_query("SELECT * FROM BEAUTYGIVEAWAY
WHERE EMAIL='$EMAIL'") or die(mysql_error());

// get the first and loop until all entries are found with the above result
while($row = mysql_fetch_array($result))
// compare the entry from the form to the result of the sql_table & the date of entry into table
if($EMAIL == $row['EMAIL'] && $nowdate == $row['DATETIME'])
{
header('Location: /contest_alert/index.html');
exit;
}
// if no entry that day - insert into sql_table
$query="INSERT INTO BEAUTYGIVEAWAY (ID, DATETIME, FNAME, LNAME, LOCATION, PHONE, EMAIL, TRACKING, NEWSLETTER, ANSWER, FAVBEAUTY, CONTEST_SUG, HELPFUL, COMMENTS, TERMS)VALUES ('NULL', '$nowdate', '$FNAME', '$LNAME', '$LOCATION', '$PHONE', '$EMAIL', '$TRACKING', '$NEWSLETTER', '$ANSWER', '$FAVBEAUTY', '$CONTEST_SUG', '$HELPFUL', '$COMMENTS', '$TERMS')";

mysql_query($query) or die ('Error updating database');

// Start the email
$email_from = 'email@email.com;//<== update the email address
$email_subject = "THIS IS JUST A TEST";
$email_body = "A new Entry for the Cosmetologist Contest has been receieved by the Database. \n".
"The entry has been sent by: \n".
" \n".
"Name: $FNAME $LNAME \n".
"Phone: $PHONE \n".
" \n".
" \n".
" \n".

$to = "email@email.com";//<== update the email address
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $email \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);
//done. redirect to thank-you page.
header('Location: /contestty/index.html');



?>

my brain hurts - when i try to ask google this question - it doesn't seem to understand.

if i should post this somewhere else in the forum please let me know...any if you need anything else!

thanks,
paul

 

coopster

WebmasterWorld Administrator coopster us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4173832 posted 12:45 am on Jul 22, 2010 (gmt 0)

if i should post this somewhere else in the forum please let me know


Same question?
[webmasterworld.com...]

onawire



 
Msg#: 4173832 posted 12:58 am on Jul 22, 2010 (gmt 0)

thanks, i posted it with my other question.

i thought it was a totally different question...

how to add a case insensitive search.

paul

coopster

WebmasterWorld Administrator coopster us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4173832 posted 1:01 am on Jul 22, 2010 (gmt 0)

The issue is resolved here then?

coopster

WebmasterWorld Administrator coopster us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4173832 posted 1:01 am on Jul 22, 2010 (gmt 0)

OK, I see. You appended this part to that post ... we'll continue discussion there instead.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved