PHP - How To Check If An Email Entered Is A Valid Paypal Email Account.
I am working on a web form in PHP which accepts a Paypal Email address from the user.
I need to authenticate (validate or check) if the Paypal email address entered is a valid Paypal email account. Please reply. All comments and feedback are welcomed. Thank you! Similar Tutorialsi wanting users to be able to update there email address and check to see if the new email already exists. if the email is the same as current email ignore the check. i have no errors showing up but if I enter a email already in the db it still accepts the new email instead of bringing the back the error message. Code: [Select] // email enterd from form // $email=$_POST['email']; $queryuser=mysql_query("SELECT * FROM members WHERE inv='$ivn' ") or die (mysql_error()); while($info = mysql_fetch_array( $queryuser )) { $check=$info['email']; // gets current email // } if($check!=$email){ // if check not equal to $email check the new email address already exists// $queryuser=mysql_query("SELECT * FROM members WHERE email='$email' "); //$result=mysql_query($sql); $checkuser=mysql_num_rows($queryuser); if($checkuser != 0) { $error= "0"; header('LOCATION:../pages/myprofile.php?id='.$error.''); } } cheers I've put together a very simple form & processing script for my site.. Everything works great except the body of the email i receive when the form is submitted contains everything but the info that has been entered into the fields. I'm sure it's something simple that I'm overlooked, but I'm officially stumped. What am I doing wrong here? <?php $mymail = 'ordietryingodt@yahoo.com'; $cc = 'New Recruit To Add!'; $BoDy = ' '; $FrOm = 'FROM:' .$_POST['t1']; $FrOm .= 'Reply-To:' .$_POST['t1']; $FrOm .= 'X-MAILER: PHP'.phpversion(); $BoDy .= 'Quake Live Name: '; $BoDy .= $_POST['t1']; $BoDy .= "\n"; $BoDy .= 'Age: '; $BoDy .= $_POST['t2']; $BoDy .= "\n"; $BoDy .= 'Residing Country: '; $BoDy .= $_POST['t3']; $BoDy .= "\n"; $BoDy .= 'Favorite Game Type: '; $BoDy .= $_POST['t4']; $BoDy .= "\n"; $send = mail("$mymail", "$cc", "$BoDy", "$FrOm"); if($send) { echo '<html><head>'; echo '<meta http-equiv="refresh" content="0;URL=/submitted.htm">'; echo '</head><body>Email send....'; echo '</body></html>'; } ?> The html Form I'm using works successfully with this php code:
<?php //check if form was sent if($_POST){ $to = 's@hmail.com'; $subject = 'Form1'; $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $headers = $name; $message .= "\r\n\r\n" . $name; if( empty($_POST["some_place"]) or $_POST['some_place'] != "glory" ) { header("HTTP/1.0 403 Forbidden"); }else{ mail( $to, $subject, $message, $email, $headers ); } header('Location: https://.......com'); exit; } ?>
The problem is that when the email is received it shows the (from) email address to be my domain account user name @ the server name, like this: Any help or suggested remedy will be appreciated This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=321126.0 Hey guys, Just lately I have been trying to start a specific project for myself. I started off by designing the pages etc on HTML, and then a friend of mine helped me convert them to PHP.
At the moment, when a user registers to the site, they only require to enter a Username and Password. I would like to add their email to it too, due to adding slightly extra security. It would also be used for future reasons such as sending emails out etc.
I'm not sure about adding this, I know that most likely it is going to be VERY similar to how it already is, but I couldn't seem to get it to work when I tried.
Ill give the coding which I am using for this below (the documents which I believe would need editing) :
Register.php
<?php require($_SERVER['DOCUMENT_ROOT'] . '/TruckWorld/includes/config.php'); $sOutput .= '<div id="register-body">'; if (isset($_GET['action'])) { switch (strtolower($_GET['action'])) { case 'register': // If the form was submitted lets try to create the account. if (isset($_POST['username']) && isset($_POST['password'])) { if (createAccount($_POST['username'], $_POST['password'])) { $sOutput .= '<h1>Account Created</h1><br />Your account has been created. You can now login <a href="login.php">here</a>.'; }else { // unset the action to display the registration form. unset($_GET['action']); } }else { $_SESSION['error'] = "Username and or Password was not supplied."; unset($_GET['action']); } break; } } // If the user is logged in display them a message. if (loggedIn()) { $sOutput .= '<h2>Already Registered</h2> You have already registered and are currently logged in as: ' . $_SESSION['username'] . '. <h4>Would you like to <a href="login.php?action=logout">logout</a>?</h4> <h4>Would you like to go to <a href="index.php">site index</a>?</h4>'; // If the action is not set, we want to display the registration form }elseif (!isset($_GET['action'])) { // incase there was an error // see if we have a previous username $sUsername = ""; if (isset($_POST['username'])) { $sUsername = $_POST['username']; } $sError = ""; if (isset($_SESSION['error'])) { $sError = '<span id="error">' . $_SESSION['error'] . '</span><br />'; } $sOutput .= '<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Truck World - Register</title> <!-- Core CSS - Include with every page --> <link href="css/bootstrap.min.css" rel="stylesheet"> <link href="font-awesome/css/font-awesome.css" rel="stylesheet"> <!-- SB Admin CSS - Include with every page --> <link href="css/sb-admin.css" rel="stylesheet"> </head> <body> <div align=center><img src="images/logintitle.png" alt="LoginTitle" /></div> <div class="container"> <div class="row"> <div class="col-md-4 col-md-offset-4"> <div class="login-panel panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Register To Join Truck World!</h3> </div> <div class="panel-body"> ' . $sError . ' <form name="register" method="post" action="' . $_SERVER['PHP_SELF'] . '?action=register"> <fieldset> <div class="form-group"> <input class="form-control" placeholder="Username" name="username" type="username" autofocus=""> </div> <div class="form-group"> <input class="form-control" placeholder="Password" name="password" type="password" value=""> </div> <div class="form-group"> <input class="form-control" placeholder="Email" name="email" type="email" value=""> </div> <!-- Change this to a button or input when using this as a form --> <input type="submit" class="btn btn-lg btn-success btn-block" name="submit" value="Register" /> <a href="login.php"class="btn btn-lg btn-success btn-block">Login</a> </fieldset>'; } $sOutput .= '</div> </div> </div> </div> </div> <div align=center><h5><small>Copyright - Lewis Pickles 2014 - All Rights Reserved</small></h5></div> <!-- Core Scripts - Include with every page --> <script src="js/jquery-1.10.2.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> <!-- SB Admin Scripts - Include with every page --> <script src="js/sb-admin.js"></script> </body> </html> '; // display our output. echo $sOutput; ?>Functions.php (Not sure if this would need editing, I think it might, Correct me if I'm wrong) <?php function createAccount($pUsername, $pPassword) { // First check we have data passed in. if (!empty($pUsername) && !empty($pPassword)) { $uLen = strlen($pUsername); $pLen = strlen($pPassword); // escape the $pUsername to avoid SQL Injections $eUsername = mysql_real_escape_string($pUsername); $sql = "SELECT username FROM users WHERE username = '" . $eUsername . "' LIMIT 1"; // Note the use of trigger_error instead of or die. $query = mysql_query($sql) or trigger_error("Query Failed: " . mysql_error()); // Error checks (Should be explained with the error) if ($uLen <= 4 || $uLen >= 11) { $_SESSION['error'] = "Username must be between 4 and 11 characters."; }elseif ($pLen < 6) { $_SESSION['error'] = "Password must be longer then 6 characters."; }elseif (mysql_num_rows($query) == 1) { $_SESSION['error'] = "Username already exists."; }else { // All errors passed lets // Create our insert SQL by hashing the password and using the escaped Username. $sql = "INSERT INTO users (`username`, `password`) VALUES ('" . $eUsername . "', '" . hashPassword($pPassword, SALT1, SALT2) . "');"; $query = mysql_query($sql) or trigger_error("Query Failed: " . mysql_error()); if ($query) { return true; } } } return false; } /*********** string hashPassword (string $pPassword, string $pSalt1, string $pSalt2) This will create a SHA1 hash of the password using 2 salts that the user specifies. ************/ function hashPassword($pPassword, $pSalt1="2345#$%@3e", $pSalt2="taesa%#@2%^#") { return sha1(md5($pSalt2 . $pPassword . $pSalt1)); } /*********** bool loggedIn verifies that session data is in tack and the user is valid for this session. ************/ function loggedIn() { // check both loggedin and username to verify user. if (isset($_SESSION['loggedin']) && isset($_SESSION['username'])) { return true; } return false; } /*********** bool logoutUser Log out a user by unsetting the session variable. ************/ function logoutUser() { // using unset will remove the variable // and thus logging off the user. unset($_SESSION['username']); unset($_SESSION['loggedin']); return true; } /*********** bool validateUser Attempt to verify that a username / password combination are valid. If they are it will set cookies and session data then return true. If they are not valid it simply returns false. ************/ function validateUser($pUsername, $pPassword) { // See if the username and password are valid. $sql = "SELECT username FROM users WHERE username = '" . mysql_real_escape_string($pUsername) . "' AND password = '" . hashPassword($pPassword, SALT1, SALT2) . "' LIMIT 1"; $query = mysql_query($sql) or trigger_error("Query Failed: " . mysql_error()); // If one row was returned, the user was logged in! if (mysql_num_rows($query) == 1) { $row = mysql_fetch_assoc($query); $_SESSION['username'] = $row['username']; $_SESSION['loggedin'] = true; return true; } return false; } ?>The Database for the email is as follows: Edited by Lewis2212, 06 August 2014 - 10:20 AM. I am sitting behind a firewall which blocks the http access to all popular free email providers like hotmail.com gmail.com .... The blocking is done by filtering out the domain names. So I am searching for a way to access the mailbox by a third domain e.g. mydomain123.com (which is under my control). I could imagine that there is a PHP code which can be setup on mydomain123.com which accesses the final hotmail.com mailbox by using POP3 fetches and SMTP sends. Is there such an PHP intermediate code? Peter Hi, i have tried everything i can think of to get this to work correctly. What is below here, is what i have last tried to work with..: basically the script allows the use to register an email account on a cpanel domain. Everything works perfectly but then i added a option for banned words now i cant get the script to work.. basically what happens is: the user creates an email account, if the account is not a banned word and does not exist, then the message echoes success, and the $_Post values are also entered into the database under the users name. and the email is also created with the $f fopen if success the email form also does not show.. so only one email per user.. i just cant get it to work with the banned words included.. what to note:: this is a function in a function.. $bannedemailwords='customerinformation,custinfo,customerinfo,custtext,custsupport,customersupport,admin,accounts'; $bannedmail=explode(',', $bannedemailwords); $bannedmail = array_unique($bannedmail); sort($bannedmail); foreach($bannedmail as $noemail) //the selected username if ($Config['enablemyemailapp_enable'] == '0' && $_POST['cfg_enablemyemailappaddress_enable'] !== $noemaill && $_POST['cfg_enablemyemailappaddressdomain_enable'] !== 'Select a domain'){ $cpuser = 'ausername'; $cppass = 'apassword'; $cpdomain = 'adomain'; $cpskin = 'askin'; $epass = 'somepassword'; $equota = 'somequota'; $euser = $_POST['cfg_enablemyemailappaddress_enable']; $epass = $_POST['emailspassword_enable']; $edomain = $_POST['cfg_enablemyemailappaddressdomain_enable']; if (!empty($euser) && $euser !=='nomail') while(true) { $f = fopen ("http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass"a=$equota", "r"); if (!$f) { $enablemyemailapp_enable = '0'; $enablemyemailappaddress_enable = 'Replace with a Name'; $enablemyemailappaddressdomain_enable = 'Select a domain'; $msgemail = 'The email '.$euser.'@'.$edomain.' is a restricted email account.'; break; } $enablemyemailapp_enable = '1'; $enablemyemailappaddress_enable = $_POST['cfg_enablemyemailappaddress_enable']; $enablemyemailappaddressdomain_enable = $_POST['cfg_enablemyemailappaddressdomain_enable']; $msgemail ='<center><font color="#ff0033">Your Email '.$euser.'@'.$edomain.' has been created.</font></center>'; while (!feof ($f)) { $line = fgets ($f, 1024); if (ereg ("already exists", $line, $out)) { $enablemyemailapp_enable = '0'; $enablemyemailappaddress_enable = 'Replace with a Name'; $enablemyemailappaddressdomain_enable = 'Select a domain'; $msgemail ='<center><font color="#ff0033">The email account '.$euser.'@'.$edomain.' already exists.</font></center><br><center>Please try again!</center>'; break; } } echo $msgemail; $_POST['cfg_enablemyemailapp_enable']= $enablemyemailapp_enable; $_POST['cfg_enablemyemailappaddress_enable']=$enablemyemailappaddress_enable; $_POST['cfg_enablemyemailappaddressdomain_enable']=$enablemyemailappaddressdomain_enable; @fclose($f); break; } } I need Delete Duplicate Email Records That Are Attached To One Account But Can Be Found In Multiple Accounts I have a table, consumer_mgmt. It collects consumer information from various forms. These forms are available through different pages that are part of a business package. A business can offer these signups to gather names and emails from consumers for various types of specials they may offer. So a consumer my be in the consumer_mgmt table 5, 10, 15 times for that particular business. But, that consumer may be in the consumer_mgmt table multiple times for a different business. So multiple times for multiple businesses. I need to remove duplicates for each business account so the consumer is only the consumer_mgmt only once for each business. There are approximately 15,000 rows currently in the consumer_mgmt table. I'm not sure where to begin on the logic. Since there are multiple business accounts that the emails are attached to, would one have to build a case for each loop? I have a contact form with a file upload button, when you click on “submit” you are redirected on Paypal everything works fine but, I would like to send the contact form only when visitors have paid on Paypal. I’ve searched on google but I have not found a way to do this. Can anyone help? Cheers, Aidan. Actually, what i want to do is to use the email to fetch the $email,$password and $randomnumber from database after does anyone have code for checking to make sure an email address is typed in correct All, In my registration script I am trying to check if an email address already exists (yawn I know), and I am stuck. The code highlighted in bold is where I want to check if the email exists (notice that form checking is done above that, including sorting out the email address that the user enters) and if it doesnt insert data into the table. Trouble is that on loading the page it simply states the 'already submitted' error before an email is even entered into the form: Code: [Select] if(isset($_POST['name']) && !empty($_POST['name']) AND isset($_POST['email']) && !empty($_POST['email']) AND ($_POST['password']) && !empty($_POST['password'])){ $name = mysql_escape_string($_POST['name']); // Turn our post into a local variable $email = mysql_escape_string($_POST['email']); $password = mysql_escape_string($_POST['email']);// Turn our post into a local variable } $name = mysql_escape_string($_POST['name']); $email = mysql_escape_string($_POST['email']); $password = mysql_escape_string($_POST['password']); if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){ // Return Error - Invalid Email $msg = 'The email you have entered is invalid, please try again.'; }else{ // Return Success - Valid Email $msg = 'Your account has been made, <br /> please verify it by clicking the activation link that has been sent to your email.'; } $hash = md5( rand(0,1000) ); // Generate random 32 character hash and assign it to a local variable. // Example output: f4552671f8909587cf485ea990207f3b [b]$emailCheck = mysql_query("SELECT email FROM users WHERE email = '".$email."'"); if (mysql_num_rows($emailCheck) > 0) { echo "already submitted"; } else {[/b] // We have a match, activate the account mysql_query("INSERT INTO users (username, password, email, hash) VALUES( '". mysql_escape_string($name) ."', '". mysql_escape_string(md5($password)) ."', '". mysql_escape_string($email) ."', '". mysql_escape_string($hash) ."') ") or die(mysql_error()); Thanks in advance, G I cannot figure out why my checkbox values are not being included in my emails I am posting my html and my php.
<form method="post" action="../leaf.php"> <input type="hidden" name="subject" value="Cleanup"> <div> <table width="425" border="0" cellspacing="0" cellpadding="0"> <tr> <td><label><span class="ie7bugfix01">Name:<span class="colour">*<br /> </span></span> <input type="text" name="contact-name" class="text" value="" /></label></td> <td><label><span class="ie7bugfix01">Email:<span class="colour">*</span></span><br /> <input type="text" name="contact-email" class="text" value="" /></label></td> </tr> <tr> <td> <label><span class="ie7bugfix01">Phone No:</span> <br /> <input type="text" name="contact-mobile" class="text" value="" /></label> </td> </tr> <tr> <td><label><span class="ie7bugfix01">Address:<br /> </span> <input type="text" name="contact-street" class="text" value="" /></label></td> <td><label><span class="ie7bugfix01">City:</span><br /> <input type="text" name="contact-city" class="text" value="" /></label></td> </tr> <tr> <td><label><span class="ie7bugfix01">Property Size:<br /> </span> <input type="text" name="property-size" class="text" value="" /></label></td> </tr> <tr> <td><label><span class="ie7bugfix01">Service request:</span><br /></label> <input type="checkbox" name="projects[]" value="Lawn Maintenance"> <label for="type1">Lawn Maintenance</label> <br> <input type="checkbox" name="projects[]" value="Mulching"> <label for="type2">Mulching</label> <br> <input type="checkbox" name="projects[]" value="Gutter Cleaning/Repair"> <label for="type3">Gutter Cleaning/Repair</label> <br> <input type="checkbox" name="projects[]" value="Revitalization"> <label for="type1">Revitalization</label> <br> <input type="checkbox" name="projects[]" value="Power Washing"> <label for="type2">Power Washing</label> <br> </td><td> <br> <input type="checkbox" name="projects[]" value="Hardscapes"> <label for="type3">Hardscape</label> <br> <input type="checkbox" name="projects[]" value="Deck Work"> <label for="type3">Deck Treatments/Repair/Construction</label> <br> <input type="checkbox" name="projects[]" value="Snow Removal"> <label for="type3">Snow Removal</label> <br><input type="checkbox" name="projects[]" value="Tree Trimming"> <label for="type3">Tree Trimming/Removal</label> <br> <input type="checkbox" name="projects[]" value="Privacy Barriers"> <label for="type3">Privacy Barriers</label> </td></tr> <tr> </tr> </table> <label><span class="ie7bugfix01">Describe your project:<span class="colour">*</span></span><br /> <textarea name="contact-comments" class="text" cols="68" rows="5"></textarea></label> <p class="submit"> <input type="submit" class="submit" value="submit" /> <input type="button" class="reset" value="reset" /> </p> </div></form> <?php $from = $_REQUEST['contact-email'] ; $name = $_REQUEST['contact-name'] ; $subject = $_REQUEST['subject'] ; $headers = "From: $from"; $headers = "Subject: $subject"; $fields = array(); $fields{"subject"} = "Subject"; $fields{"contact-name"} = "Name"; $fields{"contact-email"} = "E-mail"; $fields{"contact-mobile"} = "Phone"; $fields{"contact-street"} = "Address"; $fields{"contact-city"} = "City"; $fields{"property-size"} = "Size"; $selectedProjects = 'None'; if(isset($_POST['projects']) && is_array($_POST['projects']) && count($_POST['projects']) > 0){ $selectedProjects = implode(', ', $_POST['projects']); } $body .= 'Selected Projects: ' . $selectedProjects; $fields{"contact-comments"} = "Message"; $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $headers2 = "From: t***@toma***.com"; $subject2 = "Thank you for contacting us"; $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. By choosing TOMA you will be able to enjoy your time off with the peace of mind that your lawn is always professionally serviced. Never worry about finding time to work in the lawn again and gain back at least 35 hours of summer this season! TOMA provides weekly as needed lawn maintenance for your home or business. We are dedicated to every detail of your unique lawn. We always arrive with sharp blades, we police your property and we make sure everything is left freshly groomed and clean. Easy to sign up, easy billing, invest in your home and time today! FREE ESTIMATES WHEN YOU CALL ________. If you have any more questions, please consult our website at www.t**.com or call _________ to get started."; if($from == '') {print "You have not entered an email, please go back and try again";} else { if($name == '') {print "You have not entered a name, please go back and try again";} else { $send = mail("t***@t**.com", $subject, $body, $headers); $send2 = mail($from, $subject2, $autoreply, $headers2); if($send) {header( "Location: http://www.**t.com/thank-you.html" );} else {print "We encountered an error sending your mail, please try again"; } } } ?> I am trying to check if email already in DB. This is what I have so far and does not work. Code: [Select] if($email){ // checking user input $check_email=mysql_query("SELECT * FROM userlist WHERE email ='".$email."' "); $get_email=mysql_fetch_array($check_email); $existsmail=$get_email['email']; if($email == $existsmail){ $resultado = "Email address already exists!"; } if($email != $existsmail){ $resultado = "Your Account was created successfully! You may now login."; $date=getdate(); $insert=mysql_query("INSERT INTO userlist VALUES ('', '$name', '$phone', '$fax', '$company_name', '$billing_address', '$billing_city', '$billing_state', '$billing_zip_code', '$email', AES_ENCRYPT('$mysecretkey''password') ,now())"); }else{ $resultado = ""; } echo $resultado; } Thanks in advance. Hi all, I was just thinking that it might be possible to find out if someone read an email. If someone might want to share his thoughts on the following I would be really happy The idea i had is that instead of requiring a receipt to sign, which most free email providers don't provide. Instead send an html email with an external image with a unique name for the receiver. Ones the receiver opens the email it requests the image. This probbably isn not fool proof since someone can view in plain text, but it might be a nice thought. Is there maybe a way to track how often an image is requested and perhaps from where (IP or so). Which might not be usefull since it will come from a general email provider. This idea just popped up for me and i thought it could be nice to chat about it. If someone knows a better tracker way which is still customer friendly I would love to know : ) The idea is that in some cases it might me nice to remind someone if they didn't opn an email. Cheers! Hey, so I'm trying to check the database if the user and email already exists when registering. <?php include_once('includes/config.php'); if(isset($_POST['submit'])) { $username = $_POST['username'] ? trim($_POST['username']) : null; $password = md5($_POST['password']) ? trim($_POST['password']) : null;; $email = ($_POST['email']); $message = ""; if(empty($username) || empty($password) || empty($email)) { $message = "All fields required"; } else { $sql = "SELECT COUNT(username) AS userNum FROM users WHERE username = :username"; $sql = "SELECT COUNT(email) AS emailNum FROM users WHERE email = :email"; $stmt = $db->prepare($sql); $stmt->bindValue(':username', $username); $stmt->execute(); $row = $stmt->fetch(PDO::FETCH_ASSOC); if($row['userNum'] >0) { die("That username already exists!"); } elseif($row['emailNum'] > 0) { die("That email already exists!"); } $sql = "INSERT INTO users (username, password, email) VALUES (:username, :password, :email)"; $stmt = $db->prepare($sql); $stmt->bindValue(':username', $username); $stmt->bindValue(':password', $password); $stmt->bindValue(':email', $email); $result = $stmt->execute(); if($result) { $message = "Registration was successful"; } } } ?> If I remove this line " $sql = "SELECT COUNT(email) AS emailNum FROM users WHERE email = :email"; the code works but only checks the username. How can I check both? Hello, I'm currently using this code to check for blank fields: if(isset($_POST['submit'])) { $emailconfirm = $_POST['emailconfirm']; $user_message = $_POST['message']; $name = $_POST['name']; $visitor_email = $_POST['email']; if(empty($name)|| empty($visitor_email)|| empty($user_message)) { $errors .= "<div id='contact_form_errorloc' class='err1'>Some of the above fields have not been filled in.</div><br>"; } This however, does not check for valid emails, I've found this code: function is_valid_email($email) { $result = TRUE; if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) { $result = FALSE; } return $result; } My question was if the above is possible aswell as incorporating the blank field checks. Many thanks! Hello all. I have seen a few threads that loosely deal with ways to do this, but haven't seen anything yet that speaks to this scenario. I have a page (volunteer_signup.php) that shows events to participate in and it passes some variables to a second page (volunteer.php)which is a form for individuals to enter their credentials and that appends to the event detail passed from the first page. I want to be able to check that their email isn't already associated with this particular event, but it is allowed to be in the database for another event. I wanted to do something like the code below, but don't know how to incorporate that with the form (or in volunteerDB.php) any help would be great. thank you in advance. Code: [Select] $sql_email_check = mysql_query("SELECT email FROM users WHERE email='$email'"); $email_check = mysql_num_rows($sql_email_check); if($email_check > 0) { echo "Email is already in our database. Please enter a different email !! <br />"; } exit(); } current form: Code: [Select] <html> <?php include('dbconfig.php'); $event_id = $_GET['id']; $park = $_GET['park']; $orderdate = $_GET['orderdate']; $description = $_GET['description']; $leader = $_GET['leader']; $hour = $_GET['hour']; $min = $_GET['min']; $ampm = $_GET['ampm']; echo $orderdate; echo "<BR>"; echo $park; echo "<BR>"; echo $description; echo "<BR>"; echo $hour; echo ":"; echo $min; echo $ampm; ?> <body> <form enctype="multipart/form-data" action="volunteerDB.php" method="POST" name="myform"> <table border="1"> <input type="hidden" name="event_id" value=<?php echo $event_id; ?>> <input type="hidden" name="park" value=<?php echo $park; ?>> <input type="hidden" name="orderdate" value=<?php echo $orderdate; ?>> <input type="hidden" name="description" value=<?php echo $description; ?>> <input type="hidden" name="leader" value=<?php echo $leader; ?>> <input type="hidden" name="hour" value=<?php echo $hour; ?>> <input type="hidden" name="min" value=<?php echo $min; ?>> <input type="hidden" name="ampm" value=<?php echo $ampm; ?>> <tr> <td>First Name</td> <td> <input name="firstname" /> </td> </tr> <tr> <td>Last Name</td> <td> <input name="lastname" /> </td> </tr> <tr> <td>Email</td> <td> <input name="email" /> </td> </tr> <tr> <td>Phone</td> <td> <input name="phone" /> </td> </tr> <tr> </tr> </table> <input type="submit" value="Submit" onclick="verify();"> </td> </tr> </form> </body> </html> form feeds to this php page (volunteerDB.php): Code: [Select] <?php include('dbconfig.php'); $event_id = $_POST['event_id']; $park = $_POST['park']; $orderdate = $_POST['orderdate']; $description = $_POST['description']; $leader = $_POST['leader']; $hour = $_POST['hour']; $min = $_POST['min']; $ampm = $_POST['ampm']; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $phone = $_POST['phone']; $email_list = $_POST['email_list']; // Make a MySQL Connection mysql_connect("localhost", "$user", "$password") or die(mysql_error()); mysql_select_db("$database") or die(mysql_error()); mysql_query("INSERT INTO volunteer (id, event_id, park, firstname, lastname, email, phone, email_list) VALUES('', '$event_id', '$park', '$firstname', '$lastname', '$email', '$phone', '$email_list') ") or die(mysql_error()); ?> <?php $to = "$email"; $subject = "Trailworker Event Signup Confirmation"; $message = "Hello $firstname! Thank you for signing up to work the $park trailworker event. A crew leader will contact you shortly. Park: $park Date: $orderdate Time: $hour:$min $ampm Description: $description Crew Leader: $leader"; $from = "info@xxxxxxxxxx.com"; $headers = "From: $from"; mail($to,$subject,$message,$headers); echo "Thank you for signing up. You will receive an email shortly letting you know event details and who your crew leader is."; ?> Hello, I have looked on the forum, but haven't found the answer to this. I have a basic [name, email, phone, event] web form and want to make sure there person is not submitting twice by doing duplicate check of the mail. I looked at other solutions that suggested setting up unique IDs for each user, but it would be possible for a user to sign up for more then one event. Any info would be helpful. Not a newbie, but not an expert. |