I am just making a simple script to add peoples names to a data base for a mailing list. the first night i made it I tested it under mozilla and IE from my own apache 2 server at home. Then I uploaded it to the website host and it seemed to work. The next day it seems like when i use IE it skips over the part of code to execute if the email is valid. Now if I remember correctly.... PHP is executed on the server so the browser should have no infulence on the outcome of the code. I dont' have trouble with the variables not containing the right data.. it just seems like IE causes the server to ignore some code.. any help at all would be greatly appreciated...
aberant...
ps.. this file is called test2.php in case you were wondering what the action part of the form pointed to..
<html>
<TITLE>Abstract Email by Aberant </TITLE>
<body bgcolor="#993300" text = "FFCC99" vlink = "FFCC99" link = "FFCC99">
<?PHP
// load up the variables if they are posted...
$emailaddy = $POST['emailaddy'];
$submit = $POST['submit'];
// this narsty thing checks to see if the email is valid
function valid_email($emailaddy) {
$expression = "[-!#$%&'+./0-9=?A-Za-z{|}~]";
$expression .= "+@";
$expression .= "[-!#$%&'*+\/0-9=?A-Z^_a-z{|}~]+.[-!#$%&'+./0-9=?A-Z`a-z{|}~]+$";
if(ereg($expression, $emailaddy))
{
return 1;
} else {
return 0;
}
}
// this function inserts the email address into the database
function email_is_good ($emailaddy) {
$sql = "INSERT INTO email (emailaddy) VALUES ('$emailaddy')";
$result = mysql_query($sql);
echo "Thank you! You have now been added to the Abstract Science Email list.\n<br><br>";
echo "<a href = \"#\" onclick = \"window.close();\"><-- close window --></a>";
return 1;
}
function email_is_bad () {
echo "The email you entered does not appear to be valid<br>Make sure it is formatted like \"joe@someplace.com\" <br>";
echo "<br> <a href = \"test2.php\"><-- back</a>";
return 1;
}
// start
// display banner
echo "<h3>Abstract Email V0.1</h3>";
// connect this motha of a DB
// and test if it connected .. if not.. spit out an error message
if ( !($db = mysql_connect("www.freesql.org", "XXXXXX", "XXXXXX") ) )
{
echo "ERROR!\n Server cannot be found!<br>Please send an email to the <a href=\"mailto:webmaster@abstractscience.net\">webmaster</a><br><br> <a href = \"#\" onclick = \"window.close();\"><-- close window --></a>";
exit();
}
//connect it to the correct database.. if not spit out a message
if ( !(mysql_select_db("abstractmail",$db) ))
{
echo "ERROR!\n Database cannot be found!<br>Please send an email to the <a href=\"mailto:webmaster@abstractscience.net\">webmaster</a><br><br> <a href = \"#\" onclick = \"window.close();\"><-- close window --></a>";
exit();
}
// if the submit button is pressed.. well then do this
if ($submit){
//this calls the email validation
if( valid_email($emailaddy) ) {
//it skips this function
email_is_good ($emailaddy);
} else {
email_is_bad ();
}
} else {
?>
<form method="post" action="test2.php">
Email:<br>
<input type="Text" name="emailaddy" value="enter your email here">
<br><br>
<input type="Submit" name="submit" value="Submit">
</form>
<?php
} //end if
?>
</body>
</html>