Re: another php question
- From: needaticker@xxxxxxxx
- Date: 13 Sep 2005 05:10:35 -0700
ZeldorBlat wrote:
> Looks pretty good so far.
>
> You can check if a form variable represents a numeric string by using
> is_numeric(). It's a little bit clearer and probably a little bit
> faster than using ereg().
>
> You've already got the code in place to check that the fields are not
> empty and that $mobile contains only numbers. So the only thing left
> is to lookup $code in the database. The next section might look
> something like this (pseudocode):
>
> $sql = "select count(*) items from code_table where code = '$code'";
> //Run the query
> if (items == 0) {
> header( "Location: http://www.mysite.com/badcode.php" );
> }
>
> //Send email
> //delete the row from the database
Thanks for this but I still can't get my head around this:
So i add:
$username="username";
$password="password";
$database="databasename";
mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$sql = "select count(*) items from tablename where code = '$code'";
//Run the query
if (items == 0) {
header( "Location: http://www.mysite.com/badcode.php" );
}
What do I need to add to the above to deal with the bit about checking
that the $code value entered through the form, exists in the
'tablename' table. Because if I just insert as is I end up getting
redirected to the badcode page even though the coses are in the table
on the database.
1. Plus then I have the problem of deleteing the codes from the table
on the database if there is a match!
2. Also even if the user gets redircted to either the badcode,
badnumber or blanks pages, the email action keeps getting sent. How can
I set this so that the email doesn't get sent unless noblanks, good
mobile and good code?
Thanks for your help. I'm learning slowly!
.
- Follow-Ups:
- Re: another php question
- From: Schraalhans Keukenmeester
- Re: another php question
- References:
- another php question
- From: needaticker
- Re: another php question
- From: ZeldorBlat
- another php question
- Prev by Date: Re: KARAOKE SINGERS WANTED - the world is listening!
- Next by Date: Re: Populate picklist from directory and return file name
- Previous by thread: Re: another php question
- Next by thread: Re: another php question
- Index(es):
Relevant Pages
|