stephenhardy Posted April 9, 2008 Share Posted April 9, 2008 Hi All, I am as fresh a newbeeeeee as you could ever have the misfortune to find. I have managed to get hold of a PHP login system, which I have started to adapt. One part of it post sign up emails a confirmation code to the users provided email account. This all works, until I try and add html to the code so that I can email the end user a nice smart looking email. Anyways, heres the code, what on earth am I doin wrong, and why? Explain so I can understand, and not be such an ijit next time. <?php require_once('db.php'); include('functions.php'); include('settings.php'); if (array_key_exists('_submit_check', $_POST)) { if ( $_POST['username'] != '' && $_POST['password'] != '' && $_POST['password'] == $_POST['password_confirmed'] && $_POST['email'] != '' && valid_email ( $_POST['email'] ) == TRUE ) { if ( ! checkUnique('Username', $_POST['username']) ) { $error = 'Username already taken. Please try again!'; } elseif ( ! checkUnique('Email', $_POST['email']) ) { $error = 'The email you used is associated with another user. Please try again or use the "forgot password" feature!'; } else { $query = mysql_query("INSERT INTO users (`Username` , `Password`, `Email`, `Random_key`) VALUES ('".mysql_real_escape_string($_POST['username'])."', '".mysql_real_escape_string(md5($_POST['password']))."', '".mysql_real_escape_string($_POST['email'])."', '".random_string('alnum', 32)."')") or die(mysql_error()); $getUser = mysql_query("SELECT ID, Username, Email, Random_key FROM users WHERE Username = '".mysql_real_escape_string($_POST['username'])."'") or die(mysql_error()); if(mysql_num_rows($getUser)==1) { $row = mysql_fetch_assoc($getUser); $headers = 'From: ' . $site_email . "\r\nContent-Type: text/html; charset=iso-8859-1); " . $headers = 'Reply-To: ' . $site_email . "\r\n" . $headers = 'X-Mailer: PHP/' . phpversion(); $subject = "Activation email from " . $domain_name; $message = "Dear ".$row['Username'].", <html> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table width="800" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="600" valign="top" background="http://www.ubiqueservices.co.uklogin/email/confirmation-email.jpg"><table width="800" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="225" colspan="3"> </td> </tr> <tr> <td width="100"> </td> <td height="550" valign="top"><p>This is your activation link to join our website. In order to confirm your membership please click on the following link: <p><a href=".$url."confirm.php?ID=".$row['ID']."&key=".$row['Random_key'].">".$url."confirm.php?ID=".$row['ID']."&key=".$row['Random_key']."</a> <p>Thank you for joining</td> <td width="100"> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table></td> </tr> </table></td> </tr> </table></html>"; if ( mail($row['Email'], $subject, $message, $headers ) ) { $msg = '<head><meta HTTP-EQUIV="Refresh" content="3; URL=http://www.ubiqueservices.co.uk/login/login.php" /></head>Account created. Please refer to the confirmation email we have sent to the email address you provided during registration and confirm your membership.<br>You will now be forwarded to the Members Login Screen'; } else { $error = 'Your account has been created the account but sending the validation email out failed. Please try again later or email: [email protected]'; } } else { $error = 'An unknown error has occured. Please try again later or email: [email protected]'; } } } else { $error = 'There was an error in your request. Please make sure you filled in all the required fields, that you provided a valid email address and that the password fields match one another'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!-- Code initially from www.roscripts.com/PHP_login_scrip-143.html <!-- Adapted by Stephen Hardy 2008 --> <title>Ubique Services Test Login</title> <link href="css/styles.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="log"> <?php if ( isset ( $error ) ) { echo ' <p class="error">' . $error . '</p>' . "\n"; } ?> <?php if ( isset ( $msg ) ) { echo ' <p class="msg">' . $msg . '</p>' . "\n"; } else {//if we have a mesage we don't need this form again.?> </div> <div id="container" style="text-align:center"> <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> <input type="hidden" name="_submit_check" value="1"/> <table align="center" width="99%"> <tr> <td><div align="left">Username</div></td> </tr> <tr> <td><div align="left"><input class="input" type="text" id="username" name="username" size="32" value="<?php if(isset($_POST['username'])){echo $_POST['username'];}?>" /></div></td> </tr> <tr> <td><div align="left">Password</div></td> </tr> <tr> <td><div align="left"><input class="input" type="password" id="password" name="password" size="32" value=" /></div></td> </tr> <tr> <td><div align="left">Re-Password</div></td> </tr> <tr> <td><div align="left"><input class="input" type="password" id="password_confirmed" name="password_confirmed" size="32" value=" /></div></td> </tr> <tr> <td><div align="left">Email</div></td> </tr> <tr> <td><div align="left"><input class="input" type="text" id="email" name="email" size="32" value="<?php if(isset($_POST['email'])){echo $_POST['email'];}?>" /></div></td> </tr> <tr> <td> <input type="image" name="register" value="register" class="submit-btn" src="images/btn.gif" alt="submit" title="submit" /> <br class="clear" /> </td> </tr> </table> </form> </div> <? } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/100333-php-email-confirmation-from-a-member-sign-up/ Share on other sites More sharing options...
fri3ndly Posted April 9, 2008 Share Posted April 9, 2008 Just put another mail command in there so that it e-mails the form to you aswell: <?php mail([email protected], $subject, 'New member signed up', $headers ); ?> Link to comment https://forums.phpfreaks.com/topic/100333-php-email-confirmation-from-a-member-sign-up/#findComment-513051 Share on other sites More sharing options...
stephenhardy Posted April 10, 2008 Author Share Posted April 10, 2008 I dont know why I would want the form emailed to me? When it trys to render the regsiter.php page, it throws an error, so it wont even email the page to me. Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/ubiquese/public_html/login/register2.php on line 32 Link to comment https://forums.phpfreaks.com/topic/100333-php-email-confirmation-from-a-member-sign-up/#findComment-513644 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.