funkkube
asked on
PHP if..else option in an else section
Hi
I have the following code in a web page and I need to specify if the {$_POST['txtUsername']} is blank not to say "invalid email address"
how can i do this?
Cheers
Mat
I have the following code in a web page and I need to specify if the {$_POST['txtUsername']} is blank not to say "invalid email address"
how can i do this?
Cheers
Mat
<?php
}
}
else {
echo "Invalid email address.";
}
?>
ASKER
Hi
Thanks for that..but,,
when the page first opens the message still comes up with INVALID EMAIL which is what i am trying to get rid of..
I just need it to come once the user has pressed LOGIN - which i need to change to SUBMIT which i have just done..
cheers
mat
Thanks for that..but,,
when the page first opens the message still comes up with INVALID EMAIL which is what i am trying to get rid of..
I just need it to come once the user has pressed LOGIN - which i need to change to SUBMIT which i have just done..
cheers
mat
<p>Please register your email to gain access to vocal stems.</p>
<form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p><label for="txtUsername">Email Address:</label>
<br /><input type="text" title="Enter your Email Address" name="txtUsername" /></p>
<p><input type="submit" name="Submit" value="Login" /></p>
</form>
<p>
<?php
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['txtUsername'])) {
{
?>
Right Click on link to download the file</p>
<p> <a href="xxxxx">b vox 1</a></p>
<p>
<a href="/xxxxxx">b vox 2</a></p>
<p>
<a href="/xxxxxx">lead vox</a>
<?php
$to = "XXXXXXXXXXXX";
$subject = "REMIX COMPETITION - SOMEONE HAS DOWNLOADED THE STEMS!";
$body = "Another entry in the REMIX Competition from - {$_POST['txtUsername']}";
if (mail($to, $subject, $body)) {
echo("<p></p>");
} else {
echo("<p>.</p>");
}
?>
<?php
$myFile = "remixcomp/mercyremix.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = "{$_POST['txtUsername']} \n";
fwrite($fh, $stringData);
fclose($fh);
?>
<?php
}
}
else if($_POST['txtUsername']=='') {
echo "Invalid email address.";
}
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Genius!
Worked like a charm!
Thanks very much! :-)
Worked like a charm!
Thanks very much! :-)
ASKER
Genius!
else if($_POST['txtUsername']==
echo "Invalid email address.";
}