PHP - Non Email Activated User Warning
I would like to include: 'You have not activated your account, please check your email' message if the user is registered but not activated. The database field 'active' is set to '0'. When the user activates their account from an e-mail, the 'active' field is set to '1'. This code works but I can't get it to display the not activated message which is not included because I didn't want to create confusion.
Code: [Select] <?php function login($username, $password) { db_connect_posts(); $query = sprintf("SELECT * FROM users WHERE user_email = '%s' AND user_pwd = '%s' AND active = '1'" , mysql_real_escape_string($username), md5($password)); $result = mysql_query($query); $number_of_posts = mysql_num_rows($result); if($number_of_posts == 0) { return false; } $row = mysql_fetch_array($result); $_SESSION['user'] = $row; return true; } ?> Login switch Code: [Select] <?php case "login_user": if(login($params['user']['user_email'], $params['user']['user_pwd'])) { redirect_to('posts'); } else { flash_warning('Username or password is invalid'); $route['view'] = 'login'; } break; ?> Similar TutorialsActually, what i want to do is to use the email to fetch the $email,$password and $randomnumber from database after Hi, I have setup a standard contact form that sends an email using php "mail" function in my new website. Today, I received an email from a potential client through my website. However, unfortunately, I did not receive the user's email address because (as I discovered after wards), there was a syntax problem in the function, so all I received is their name and message. I am certain that the user has entered their email address because the form has validation, it just didn't send me the address so I have no way to contact that client... Is there a way to retrieve the lost email address from the server somehow? Thanks in advance I am having a problem with my User Log-In... When a User creates an account on my website, an e-mail is sent that looks like this... Quote Congratulations! Your account has been created, and a confirmation e-mail sent to: "john.doe@mail.com" Please click on the link in that e-mail to activate your account. Then when they click on the link, it takes them to my 'activate.php" page which updates the User's record by removing the Activation Code. The "Activation" seems to work fine. However, the problem that I just realized is that I am doing nothing to prevent someone from Registering, NOT Activating his/her account, but still being able to Log In?! I guess what I need to do when a User logs in is check to be sure that the "activation_code" column is NULL, right? Here is a snippet of my Log In script... if (empty($errors)){ // Valid form data. // ************************ // Find Member Record. * // ************************ // Connect to the database. require_once(WEB_ROOT . 'private/mysqli_connect.php'); // Build query. $q = 'SELECT id, first_name FROM member WHERE email=? AND pass=?'; // Prepare statement. $stmt = mysqli_prepare($dbc, $q); // Bind variables to query. mysqli_stmt_bind_param($stmt, 'ss', $email, $pass); // Execute query. mysqli_stmt_execute($stmt); // Store results. mysqli_stmt_store_result($stmt); // Check # of Records Returned. if (mysqli_stmt_num_rows($stmt)==1){ // Member was Found. // Bind result-set to variables. mysqli_stmt_bind_result($stmt, $memberID, $memberFirstName); // Fetch record. mysqli_stmt_fetch($stmt); // Set Session variables. $_SESSION['memberID'] = $memberID; $_SESSION['memberFirstName'] = $memberFirstName; $_SESSION['loggedIn'] = TRUE; What would be the best way to fix this? Thanks, Debbie hi all, im working on a email send to de user who register on the website! now i get the email but its not email/html view and it gets in to the unwanted folder, also as i siad trust this emailadress! what do i wrong in the code?? the whole php file see //#### XXX ### where i need help! Code: [Select] <?php Session_start(); if(file_exists("support/functions_alg.php")) // user,pass and database file { include("support/functions_alg.php"); // database functions file } if($_REQUEST) { $email=$_REQUEST['email']; $pass=md5( $_REQUEST['pass'] ); $secc=md5( $_REQUEST['sec_code'] ); function check_code($secc) { if($secc == $_REQUEST['mdcode']) { return true; } else { return false; } } function check_email_address($email) { // First, we check that there's one @ symbol, and that the lengths are right if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } if(check_email_address($email)) { if(check_code($secc)) { //$res=register($email,$pass,$name,$address,$huisnr,$zipcode,$plaats,$dob_year,$dob_month,$dob_date,$tel); $res=true; if($res==true) { // ##### XXX ##### //mail function /* subject */ $subject = "Activeer uw Profiel"; /* To send HTML mail, you can set the Content-type header. */ $headers = "MIME-Version: 1.0 \r\n"; $headers .= "Content-type: text/html; charset=utf-8 \r\n"; /* additional headers */ $headers .= "From: " . $mailme . " \r\n"; /* and now mail it */ $text = ' <html> <head> <title>Nieuw profiel</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> Activeer uw profiel op:<br><br> <a href="http://'.$_SERVER['SERVER_NAME'].'/?reg_result&activatie=true">Activeer</a>br><br> Veel plezier op onze website! </body> </html>'; $res = mail($email,$subject,$text,$headers); echo("<script>document.location.href='index.php?topic=reg_result&".$res."'</script>"); //header('location: "'.$_SERVER['HTTP_REFERER'].'?topic=reg_result&true"'); //###### XXXX ####### } else { echo "<table border=1 class=outer_tbl align=center width=50% style='border-collapse:collapse;'>"; echo "<tr><td align=center>"; echo "Fout tijdens registratie<br><a href='javascript:history.back();'>Klik hier</a> om opnieuw te proberen"; echo "</tr></td></table>"; } } else { echo("<script>document.location.href='".$_SERVER['HTTP_REFERER']."&error=code'</script>"); //header('location: "'.$_SERVER['HTTP_REFERER'].'&error=code"'); } } else { echo("<script>document.location.href='".$_SERVER['HTTP_REFERER']."&error=email'</script>"); //header('location: "'.$_SERVER['HTTP_REFERER'].'&error=email"'); } } ?> the recived email looks like : Content-type: text/html; charset=utf-8 From: info@pc-hulp-online.nl Return-Path: anonymous@server70.hosting2go.nl X-OriginalArrivalTime: 30 Apr 2012 10:47:41.0985 (UTC) FILETIME=[AB19D110:01CD26BE] <html> <head> <title>Nieuw profiel</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> Activeer uw profiel op:<br><br> <a href="http://nieuw.pc-hulp-online.nl/?reg_result&activatie=true">Activeer</a>br><br> Veel plezier op onze website! </body> </html> please help me!! thnx, Hi I have created several php scripts which adds a user to the database and allows them to login aswell. I want an email confirmation link in which the user has to click in order for them to get added to the database. Below is my code any help in what php I put in and where would be most helpful, thanks in advance. Chris *********************************************************************** mainregister.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Web Server</title> <link href="css/style.css" rel="stylesheet" type="text/css" /> </head> <body> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="checkregister.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Member Login </strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="myusername" type="text" id="myusername"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="mypassword" type="text" id="mypassword"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Register"></td> </tr> </table> </td> </form> </tr> </table> </body> </html> ****************************************************************************** checkregister.php <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="webserver"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="INSERT INTO $tbl_name (username,password) VALUES('$myusername','$mypassword')"; $result=mysql_query($sql); echo "Registered to database"; ?> </body> </html> Hi, ive been looking all over for a script to send an email once users on my site register their details, is this possible? all i want is it to send their username and password. Also the same sort of thing is needed for the "lost password" button? Any help suggested would be great, many thanks. Web Form/Registration: Code: [Select] <form action="sendAd.php" method="post"> <h4 class="style7">Type of company (Removal, Transport, Storage, Insurance, Local Area or Other):<br /> <input type="text" name="type"/> <br />Company name:<br /> <input type="text" name="company_name"/> <br /> Location:<br /> <input type="text" name="location"/> <br /> Six bullet point description of your company:<br /> <textarea rows="6" cols="21" name="description" ></textarea> </h4> <h4 class="style7"> <br /> <input name="submit" type="submit" id="submit" value="List your ad" /> </h4> <p> </p> </form> SendAd.php: Code: [Select] <?PHP $user_name = ""; $password = ""; $database = "removal2"; $server = "server"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "INSERT INTO ads (type, company_name, location, description) VALUES ('" .$type. "', '" .$company_name. "', '" .$location. "', '" .$description. "')"; $result = mysql_query($SQL); mysql_close($db_handle); header( 'Location: http://www.removalspace.com/advert-confirm.php' ); exit(); } else { print "Database NOT Found "; mysql_close($db_handle); } ?> MOD EDIT: code tags added. I am working on user validation through email and I am having some problems with it. I can get it to work but it gives me probloms some times. This is the link that is sent to the users after they sign up Code: [Select] mydomain/confirm.php?id=".$id."&userkey=".$userkey and this is what i have for the confirm page Code: [Select] <?php //connection info $userquery = mysql_query("SELECT * FROM user"); $active=mysql_result($userquery, "active"); $userid=mysql_result($userquery, "id"); $userkey=mysql_result($userquery, "userkey"); if ($active == 1) { printf("This account has already been activated"); echo "<br />"; } elseif($userkey != $posteduserkey){ printf("We are sorry but the data offered does not match data listed, plese contact system admin."); } else{ $query="UPDATE user SET active='1' WHERE id='$id'"; mysql_query($query) or die (mysql_error()); echo "You have activated your account"; ?> <div align="center"><br /><a href="login.php" class="nav">Back to the log in page</a></div> <?php } ?> This is the fun part. I checked that the id and userkey are correct in the link, and they are. I then replaced the & in the link with & it works in gmail but not yahoo email address. I'm not sure where else to look. Thanks in advance i use a user management system which can be download this from http://rapidshare.com/files/39584153...LL-DGT.zip.rar i also have a script which emails a link to the entered email address.... i want it to check if the entered email matches with the logged in users email on the database..... this email script can be downloaded from http://rapidbay.net/download/1364276...kurl-v1-7.html as im totally new to php i wud appriciate if u cud explain a lil bit.. pls help.... Am trying to get an email address from the DB and send an alert but it's not working..
$search3 = mysql_query("SELECT email FROM users WHERE department = '$department' AND (position = '$position')") or die(mysql_error()); $acct1 = mysql_fetch_array($search3); $email = $acct1['email']; $to = $email; $subject = 'New Requisition Alert'; $message = 'You have a new message'; $headers = 'From: server@test.com' . "\r\n" . 'Reply-To: admin@test.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); Hi there, ths is my very first post to this site so thanks in advance for reading and suggesting. (And apologies if this is not correct forum) I have a website that generates some output ( onto website File A). I want to email this output that's generated to a users (inputted) email address. I cant quite work out how to get that output into the email. I can cut and paste (into $menu variable in file B) but i want to have it done automatically. So far i have the following code (and maybe there's an easier way/ better way), but this is what i have so far. in file A, I have the PHP/MySQL generated output and an "email" icon that displays ( <input type='image' onClick='myPopup()' img src='email1.jpg' alt='' width='100' height='100' vspace='5' border='10' align='left' ALT='Email' value='Email' /> ) this redirects to file B (which pops up and asks for the email address to send generated output of file A to) when user clicks email button.. It seems from my investigations so far that I somehow have to get it into $menu variable of file B but am unsure how, or if there is another way (to how i'm trying)? In IE7 under Page dropdown, there's an option to 'Send page by -Mail...' this is what i want mine to do Could someone have a look and see if there's something I could try - thanks very much file B = <html> <head> <link rel="stylesheet" type="text/css" media="all" href="style.css"/> <title> Email menu </title> </head> <body> <h3><p align="center"><u>Email menu & nutritional information</u></p></h3> <br><br><br> <?php echo "<br>"; echo "<br>"; echo "<br>"; ?> <p><font color="orangered" size="+1"><tt><b>*</b></tt></font> indicates a required field</p> <form method="post" action="<?php echo $_SERVER['PHP_SELF']?>"> <table border="0" cellpadding="0" cellspacing="5"> <tr> <td align="right"> <p>Email </p> </td> <td> <input name="email" type="text" maxlength="50" size="40" /> <font color="orangered" size="+1"><tt><b>*</b></tt></font> </td> </tr> <tr> <td align="right" colspan="2"> <hr noshade="noshade" /> <input type="reset" value="Reset Form" /> <input type="submit" name="submitok" value="EMAIL menu" onClick="javascript:window.close();"/> </td> </tr> </table> <?php $menu="if i cut and paste file A content, it does send but i want automated"; if (isset($_POST['submitok'])){ $message = "Your menu and the nutritional information for that menu below $menu; Kind regards, "; mail($_POST['email'],"Your menu",$message); Header("Location: print_menu_restrict.php"); } ?> </body> </html> 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? I want to do something like this,
I had a html query submission form linked to php.
I want to send the output generated after php execution to the user through mail id provided in the form, in a manner such that when user click submit button, he well be redirected to thank you page and php keeps on running in the background and as soon as the output is generated, it will be send to the end user through email. As my query takes time to execute, so I don't want the end user to keep waiting till the program gets finish.
Here is my code:
<?php $seq = $_POST['seq']; if (isset($_POST['seq'])) { $b = fopen("sequence.txt", "w"); fwrite($b, $seq); fclose($b); system("perl /opt/lampp/htdocs/matepred/blast/bin/scriptforblastcompleterun.pl sequence.txt nr > out"); system("perl /opt/lampp/htdocs/matepred/blast/bin/format.pl > output"); system("perl /opt/lampp/htdocs/matepred/blast/bin/testing.pl output"); echo "<div align='center'><font color='blue'><b>RESULT</font></div>"; $i=1; $files = array(); foreach (glob("file_*.out")as $file) { $files[] = $file; $b = fopen("/opt/lampp/htdocs/matepred/blast/bin/$file", "r"); $s=fgets($b); fclose($b); echo "<table border=10. align=center><tr bgcolor=lightgreen><th>SerialNo</th><th>Value</th><th>Decision</th><th></tr>"; echo '<td>'. $i++. '</td>'; echo "<td>$s</td>"; if($s>=0) { echo "<td>Yes</td>"; } else { echo"<td>No</td>"; } echo "</table>"; } } ?> html table part marked in red here is the output which I want to send back to the user. Can anybody help me in linking my php output to the mail. Thanks in advance. i want to send email to multiple user.this is my code: Hi all, I am quite new to PHP and MySql. I know how to upload a file a and save the path in the DB, but now I need to send an automatic email to the user when a new invoice is added to his directory. Please help. Thanks Hi I built a really simple customer review form https://kickasssoftwear.uk/dev/reviews.html (it's only been optimised for mobile view so far) and it works using the php mail script on this page https://kickasssoftwear.uk/dev/empty2.php - the emails are being sent to me and the format of the emails is OK, and the form redirects to the empty2 page with a mailsent message in the address bar. I know I can leave that page as is and write a nice thank you message in the html - but what I really want to do is have the customers name there too, Thanks 'name' your review has been sent, but I can't get it to work - it's been 4 whole days now and I really need to eat & sleep! Please if anyone has suggestions or advice for a noob, please help. Thanks Hi, I want to create a forgotten password page, where the user enters in their email address, the script queries the database for that email address, creates a unique ID, stores that unique ID in the database, then emails the unique ID and the User ID off to the user in an HTML link e.g. http://somesite.com/reset-password.php?userId=2&uniqueId=132832189312978312. The reset page would then match the unique ID to the one in the database and let them enter in a new password into the form. Ok so I can do most of that so far except from the emailing to the user. I'm running an Ubuntu Server 10 at the moment as my test server which is on my local network. Do I need to set up a mail server on that for php mailing to work, or can I use some external SMTP for sending? I've had a play round with the PHP mail() function but it won't send anything at the moment. I'll also need some code for when the site is running in the hosted live environment as it will likely use their mail servers. What's the best way to go about doing this? Many thanks! guys this function below posts the data into table and im also able to send a link in email with caregory name but the issue is getting the id to the particular post i got no isea how do i get that? Code: [Select] function insert($postData) { $postData['description'] = clean($postData['description']); if(!EmailExists($postData['email'])){ $sql = " INSERT INTO tbl_emails SET email = '".$postData['email']."', postersname = '".$postData['postersname']."', phone = '".$postData['phone']."' "; executeSql($sql); } if(empty($_FILES['image']["name"])){ $sql = " INSERT INTO tbl SET title = '".$postData['title']."', image = '', postersname = '".$postData['postersname']."', category = '".$postData['category']."', type = '".$postData['type']."', state = '".$postData['state']."', location = '".$postData['location']."', email = '".$postData['email']."', phone = '".$postData['phone']."', description = '".$postData['description']."', time = '".time()."' "; executeSql($sql); }else{ global $uploadPath; $remove_symbols = array('+', '=', '-', '{', '}', '$', '(', ')','&'); $removed_symbols = str_replace($remove_symbols, "_", $_FILES['image']['name']); $randomnum=rand(00000000,99999999); $imagepath = uploadFile($_FILES['image'], $uploadPath); $image = new SimpleImage(); $image->load($imagepath); $image->resize(250,280); $resize_rename = $uploadPath.$randomnum._.$removed_symbols; $image->save($resize_rename); unlink($imagepath); //delete the original file $sql = " INSERT INTO tbl SET title = '".$postData['title']."', image = '".$resize_rename."', postersname = '".$postData['postersname']."', category = '".$postData['category']."', type = '".$postData['type']."', state = '".$postData['state']."', location = '".$postData['ocation']."', email = '".$postData['email']."', phone = '".$postData['phone']."', description = '".$postData['description']."', time = '".time()."' "; executeSql($sql); } } This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=321126.0 |