Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question no compile, no debugger

    Hiya,
    Sorry to post such a big chuck of code for a first-time post, put I need a second set of eyes on this. It won't compile and I don't have a debugger to go through it (can't seem to make any of the popular ones work :'( )
    Here's 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've been all over this code and I still can't figure out where I'm going wrong. Maybe you can.
    Thanks.
    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."
    }
    
    ?>

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,149
    Thanks
    2
    Thanked 333 Times in 325 Posts
    What errors are you getting or are you getting a blank page?
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    error messages

    Thus far, I'm just getting a blank page, so it has to be a compile error...

    ...right?

  • #4
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,149
    Thanks
    2
    Thanked 333 Times in 325 Posts
    Blank pages are usually caused by open quotes or open {.

    I checked your code and there are a number of "return..." statements. If this code is not within a function, than these have no meaning and I am not sure what the run time results would be.

    Edit: In case anyone read that, the source code does have back-slashes to escape the double-quotes.

    Also between lines 64 and 65, you are trying to use the . to concatenate two strings, but the . is inside of the double-quoted string on line 64.
    Last edited by CFMaBiSmAd; 11-25-2006 at 11:21 PM.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #5
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I took a second look and my concatenation at line 64 was wrong. Dreamweaver evidently didn't pick that up. Thanks.

    Unfortunately, the code still doesn't compile. I'll keep scanning my code and see if I can't find a curly bracket error or something else. It's always the little things that screw up a perfectly good app.

    Thanks for the help!
    -E
    Last edited by ars_moriendi; 11-25-2006 at 11:32 PM. Reason: moot point

  • #6
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    you should probably setup your server so it reports errors to you rather than dying silently.

  • #7
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question php error reporting

    I'm on a hosting service.
    Any way I can set this up me-self?
    -Ars

  • #8
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile problem solved

    Do you ever feel, at times, that if you were any dumber, someone would probably have smothered you in your sleep to save the rest of the world undue anguish?

    Yeah...

    Turns out, I had an echo statement right at the end that didn't have a ';' to finish it.
    Do you see?
    DO YOU SEE how easy it is to be a moron?
    I'm going to practice my Morrisey impersonation in the corner and then see if I can't wrap the rest of this project up.
    Thanks for the help, guys.

    -Ars


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •