Jump to content

no compile and no debugger


ars_moriendi

Recommended Posts

First off, let me apologize for posting a big ol' chunk o'code, but I've been up and down this 100+/- line script for the past day and I can not, for the life of me, figure out why it ain't compiling.
What it's supposed to do:
* double-opt in email address verifier and collector: someone comes to a basic form, types in their name and email. This script checks the form information for errors, makes sure it's not already in a mysql database, makes a uniquely cyphered identifier out of their email, and sends that identifier to them in a link back to the script. When they click on that link, this script grabs the relevant info, throws it in the database and welcomes them into Omerta (pretty much).
I don't think it's anything most people haven't seen before which is why I'm mystified about what I'm doing wrong. I'm thinking that being up for 20+ hours may have something to do with my not being able to find the error, but Thanksgiving weekend is over in two days and I'm on a deadline.
So, here I am, asking for help. If you have a minute, skim over it and tell me where I went wrong.
Much love,
-Ars
[code]
<?
//collect visitor's name and email from form or address bar
$from = $_REQUEST['user_add'];
$from = urldecode($from);
$frommail = $_REQUEST['email_add'];
$frommail = urldecode($frommail);

//make sure they put something in the form
if(empty($from) || empty($frommail)) {
echo "<h2>Dude, we can't do this without your help!</h2><br>".
"Use your browser's back button to enter your information and try again.";
return 1;
}

//make sure email address is real.
if(eregi("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $frommail)) {
$username="[redacted]";
$password="[redacted]";
$database="[redacted]";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$prequery="Select email from newsletter where email='".$frommail."'";
$exists = mysql_query($prequery) or die("Error #:".mysql_errno()."<br>".mysql_error());
mysql_close();
//check for existance in DB
if($row = mysql_fetch_array($exists)) {
?>
<h1>Welcome back, <?php echo $from ?>!<br></h1>
<h3>We're glad you like the newsletter so much, but you don't need to sign up twice.
Thanks to the magic of the internet, you can forward, copy or blind carbon copy
it to anyone, anywhere and all to your little heart's content. That being said,
we hope you don't mind us restricting you to just the one. I mean, come on.
We've got bills to pay, you know?</h3>
</body></html>
<?
return 1;
}
else {
//turn email into unique ID.
$cypher = "[redacted]";
$formatted_email = preg_replace("/(-|\@|\.)/", "", $frommail);
$h_email= md5("$cypher $formatted_email");

//if validating, put visitor in DB
if($_REQUEST['m'] != "") {
if($h_email == $_REQUEST['m']) {
$username="[redacted]";
$password="[redacted]";
$database="[redacted]";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="INSERT INTO newsletter VALUES ('".$from."','".$frommail."')";
mysql_query($query) or die(mysql_error());
mysql_close();
echo "Congratulations,".$from.". You're now part of the Marco's Taxi".
"family. From now on, every time you walk down the street, you'll gaze ".
"upon your fellow man or woman and wonder: \"Are they one, too?\" ".
"You may be tempted to ask them as much, but be warned. The oath".
" you've sworn is unbreakable...like <a href=\"http://en.wikipedia.org/wiki/Omerta\">Omerta</a>.".
" You're one of us now, paisano. You're made. The world is yours.";
return 1;
} else {
echo "Sorry, this email does not validate. ".
"Go <a href=\"index.html\">back</a> ."
"and try again, buckaroo.";
}
}
//if not yet validating, create and send validation email
else {
$url_from = urlencode($from);
$url_mail = urlencode($frommail);
$mail_body = "To validate this email click the following link:\n".
"[URL redacted]signup.php?user_add=".$url_from."&email_add=".$url_mail."&m=".$h_email."\n\n".
"Unfortunately, not every email program knows how to hold together URLs, ".
"so if clicking on the link doesn't work, just cut and past it into the ".
"address bar of your browser.\n".
"And by the way, thanks!";
mail($frommail, "*Marco's Taxi Email Validation*", $mail_body, "From:[redacted]\n");
?>
<p align="left">
<h1>Thanks, <?php echo $from ?>!<br></h1>
&nbsp &nbsp &nbsp &nbsp We've gone ahead and sent an email to
<b><?php echo $frommail ?>
</b> with a link that lets you verify your email with us.
If the email you gave us is wrong or isn't yours, don't worry.
We all screw up every now and again.
Go back and try it again. <br />
&nbsp &nbsp &nbsp &nbsp If everything looks good, <a href="fleet">click
here</a> to gaze once again upon our majestic fleet.
<?
}
}
else
{
echo "<h2>".$frommail." ain't a real email address!</h2><br>".
"Use your browser's back button to correct your email address."
}

?>

[/code]
Link to comment
https://forums.phpfreaks.com/topic/28411-no-compile-and-no-debugger/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.