Jump to content

abhishekdeveloper

Members
  • Posts

    34
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

abhishekdeveloper's Achievements

Member

Member (2/5)

0

Reputation

  1. I have the following code to retrieve the password of a user from the database and email to him. I am successfully able to send a user his password if his email is present in the database. But in the event that the email doesn't exist, I want the code to echo that the email for the particular user doesn't exist in the database. My code gives me the below result if an invalid email is entered in the form: Failed to add recipient: @localhost [sMTP: Invalid response code received from server (code: 555, response: 5.5.2 Syntax error. v9sm2318990paz.6)] I have tried using the if-else statement for this purpose. Here's the code I wrote: <?php //Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); // email value sent from HTML form $email_to=$_POST['email']; // table name $tbl_name="registration"; if($mysql1 = "SELECT ID,Email,Password FROM $tbl_name WHERE Email='$email_to' ORDER BY ID DESC ") { $selectemail = mysql_query($mysql1); $shah = mysql_fetch_array($selectemail); $EMAIL = $shah['Email']; $UID = $shah['ID']; $password = $shah['Password']; require_once "/home/computat/php/Mail.php"; $from = "abhishekagrawal.988@gmail.com"; $to = $EMAIL; $subject = "Your password for www.computationalphotography.in"; $body = "Your password for logging on to our website www.computationalphotography.in is:\n$password\r\nIf you have any additional queries, kindly write to us at abhishekagrawal.988@gmail.com\r\n\nThanks & Regards\nThe Computational Photography Team\n"; $host = "ssl://smtp.gmail.com"; $port = "465"; $username = "abhishekagrawal.988@gmail.com"; // $password = "*********"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p></p>"); } } else{ echo "<b><center>Email not found in the database</center></b>"; } /*
  2. Hi Barry, Thank you for your reply. I incorporated the change that you mentioned. But I am still unable to see the change in my database against the particular user name in the respective table against the particular username. Please let me know if there are any other modifications required, below is my modified code: <?php $character_set_array = array( ); $character_set_array[ ] = array( 'count' => 5, 'characters' => 'abcdefghijklmnopqrstuvwxyz' ); $character_set_array[ ] = array( 'count' => 1, 'characters' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ); $character_set_array[ ] = array( 'count' => 1, 'characters' => '0123456789' ); $character_set_array[ ] = array( 'count' => 1, 'characters' => '!@#$+-*&?:' ); $temp_array = array( ); foreach ( $character_set_array as $character_set ) { for ( $i = 0; $i < $character_set[ 'count' ]; $i++ ) { $temp_array[ ] = $character_set[ 'characters' ][ rand( 0, strlen( $character_set[ 'characters' ] ) - 1 ) ]; } } shuffle($temp_array); $output=implode($temp_array); echo "<b><b><P ALIGN=Center>$output</P></b></b>"; //this is where the code stores the output in the database $host="localhost"; // Host name $username="computat_abhi"; // Mysql username $password="1123581321"; // Mysql password $db_name="computat_rajesh"; // Database name // Connect to server and select database. $handle = mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db($db_name,$handle)or die("cannot select DB"); mysql_select_db("computat_rajesh",$handle); $sql="INSERT INTO registration (CompletionCode) VALUES ('$output')"; $result = mysql_query($sql); mysql_close($handle); ?>
  3. Dear All, I have a website on which the users vote on a set of images. A script that generates a random code immediately after a particular user has finished voting on an image. Below is the script to generate and store this code in the table in the column titled CompletionCode. However, after running the script, I am unable to see the random number stored in my database in the CompletionCode column. Kindly help me out by suggesting changes/modifications: <?php $character_set_array = array( ); $character_set_array[ ] = array( 'count' => 5, 'characters' => 'abcdefghijklmnopqrstuvwxyz' ); $character_set_array[ ] = array( 'count' => 1, 'characters' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ); $character_set_array[ ] = array( 'count' => 1, 'characters' => '0123456789' ); $character_set_array[ ] = array( 'count' => 1, 'characters' => '!@#$+-*&?:' ); $temp_array = array( ); foreach ( $character_set_array as $character_set ) { for ( $i = 0; $i < $character_set[ 'count' ]; $i++ ) { $temp_array[ ] = $character_set[ 'characters' ][ rand( 0, strlen( $character_set[ 'characters' ] ) - 1 ) ]; } } shuffle($temp_array); $output=implode($temp_array); echo "<b><b><P ALIGN=Center>$output</P></b></b>"; //this is where the code stores the output in the database $host="localhost"; // Host name $username="computat_xyz"; // Mysql username $password="1234"; // Mysql password $db_name="computat_pqr"; // Database name // Connect to server and select database. $handle = mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db($db_name,$handle)or die("cannot select DB"); $sql="INSERT INTO registration (CompletionCode) VALUES ('$output')"; mysql_close($handle); ?>
  4. Dear All, Below is a program that generates a random password each time the page loads, I am getting an unexpected output as "Array" on running the script: <?php $character_set_array = array( ); $character_set_array[ ] = array( 'count' => 5, 'characters' => 'abcdefghijklmnopqrstuvwxyz' ); $character_set_array[ ] = array( 'count' => 1, 'characters' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ); $character_set_array[ ] = array( 'count' => 1, 'characters' => '0123456789' ); $character_set_array[ ] = array( 'count' => 1, 'characters' => '!@#$+-*&?:' ); $temp_array = array( ); foreach ( $character_set_array as $character_set ) { for ( $i = 0; $i < $character_set[ 'count' ]; $i++ ) { $temp_array[ ] = $character_set[ 'characters' ][ rand( 0, strlen( $character_set[ 'characters' ] ) - 1 ) ]; } } shuffle( $temp_array ); implode( '', $temp_array ); echo $temp_array; ?> I am expecting output in the below format: mczt0:Rm 2dwvJp!v wo9iVk@b c5xmx:xR a!Xwm5qk oyv!p8Sg Tiu8rb&w rmw&fa1I Kindly help me out by suggesting changes/modifications/errors. Thank you.
  5. I am sorry but same error....I guess I need to put the source code file on the server in the same folder for all these functions self.close, windows.close() etc.
  6. It is not the parent of the entire website...it is the page that opens after the user is done using the website for the purpose it was intended to do...
  7. It is a page written in html/php, i tried HTML script using self.close() but it is also giving the not found error...help!
  8. I am not sure if my window is opened using javascript...and self only works if a window is opened using javascript. Can you please help me out in this regard? I want it to work on all the platforms. Thank you.
  9. Even if I try the below code, it gives me the error: Not Found The requested URL /self.close() was not found on this server. Here's the script: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <title> Thank you! </title> <body bgcolor="#808080"> <br> <br> <h2><P ALIGN=Center>Thank you for voting on our website!</h2> <h3><P ALIGN=Center>We will e-mail you the results of the experiment shortly!</h3> <br> <br> <P ALIGN=Center><a href="login_success.php">Click here to go back and change your votes</a> <br> <br> <P ALIGN=Center><a href="self.close()">Click here to close this window</a> </body> </html> Please suggest modifications asap. Thank you.
  10. Dear All, Below is my script for closing a window, I intend to close the window. Please help me out. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <title> Thank you! </title> <body bgcolor="#808080"> <br> <br> <h2><P ALIGN=Center>Thank you for voting on our website!</h2> <h3><P ALIGN=Center>We will e-mail you the results of the experiment shortly!</h3> <br> <br> <P ALIGN=Center><a href="login_success.php">Click here to go back and change your votes</a> <br> <br> <P ALIGN=Center><a href="" onclick="window.close();return false;">Click here to close this window</a> </body> </html> It is not working as I intend it to work, any suggestions??
  11. My problem is solved. Thank you for your help .
  12. Thank you for your reply, I have reformatted my output and modified my code. However, I am still getting the same error which is Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/computat/public_html/forgotpassword.php on line 29 Here's my modified code: <?php include_once"configure.php"; $email=$_POST['email']; $email=mysql_real_escape_string($email); if($email<>"") { $check_user_data = mysql_query("SELECT * FROM registration WHERE email = '$email'") or die(mysql_error()); if(mysql_num_rows($check_user_data) == 0) { echo '<script language="javascript">alert("This email address does not exist. Please try again.")</script>;';unset($email); } else { $row = mysql_fetch_array($check_user_data); $email=$row['email']; } $to = $email; $subject = "Here are your login details . . . "; $message = "This is in response to your request for login details on www.computationalphotography.in.\nYour username is $row['email']\n.Your password is $row['password']"; if(mail($to, $subject, $message, $headers)) { echo "<center><font face='Verdana' size='2'><b><br><br><br><br><br>THANK YOU</b> <br>Your passwords are posted to your email address. Please check your mail soon.</center>"; } else { echo "<center><font face='Verdana' size='2' color=red>There is some system problem in sending login details to your address" <br><br> <input type='button' value='Retry' onClick='history.go(-1)'></center></font>"; } } ?>
  13. Dear All, I have written the following code for "Forgot Password" link on my website www.computationalphotography.in. Below is my code: <?php include_once"configure.php"; $email=$_POST['email']; $email=mysql_real_escape_string($email); if($email<>""){ $check_user_data = mysql_query("SELECT * FROM registration WHERE email = '$email'") or die(mysql_error()); if(mysql_num_rows($check_user_data) == 0) {echo '<script language="javascript">alert("This email address does not exist. Please try again.")</script>;';unset($email);} else {$row = mysql_fetch_array($check_user_data);$email=$row['email']; $to = $email; $subject = "Here are your login details . . . "; $message = "This is in response to your request for login details on www.computationalphotography.in.\nYour username is $row['email']\n.Your password is $row['password'].\n"; $headers = "From: ".$psbhostemailaddress."\r\nReply-To: ".$email; if(mail($to, $subject, $message, $headers)){echo "<center><font face='Verdana' size='2'><b><br><br><br><br><br>THANK YOU</b> <br>Your passwords are posted to your email address. Please check your mail soon.</center>";} else{echo "<center><font face='Verdana' size='2' color=red>There is some system problem in sending login details to your address. <br><br><input type='button' value='Retry' onClick='history.go(-1)'></center></font>";} }} ?> On execution I am receiving the error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/computat/public_html/forgotpassword.php on line 22 Kindly help me out! Thank you.
×
×
  • 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.