PHP - Lost Password With Md5
Since I cant undo the MD5 is it safe to say record their password again with out MD5 in the data base and use that to mail them their password if they forgot it?
Similar TutorialsOkay I am a beginner and haven't coded in months. I am trying to find a tutorial or help figuring out how to build a lost password script for user log-in system I built a while ago. Can anyone help with either something that works that I can learn from, a tutorial somewhere? thanks Tim I need to come up with a better way to do this. Currently I have a script which is a form and the user enters their email address, and their password in the database is sent to the email address. Problem is the password is MD5 hashed, so it's hashed when sent to their email. I am sure there is a better way to do this. Also, I am capturing a Security Question and Answer in the initial profile form that the user fills out, so I need to incorporate this as an extra layer of security. Please let me know of the methods for doing this. Thanks in advance! I've never actually done a username password, retrieval script before so need a little help. In the profile form the user is submitting username/password/name/email etc. into a MySQL DB along with a security question and answer. Is it just a matter of creating a form which does a check against the database and sends out an email to the user with their password? The password is hashed with MD5, so how would I send out an un-hashed PW? thanks! Hello PhP Freaks forum In the past weeks ive been trying to make a website, where you can register. Everything seems to work except my cherished Change password feature. Everytime you try to change the password, it just resets it to nothing. Here is the code below. <?php if(isset($_SESSION['username'])) { $username = $_SESSION['username']; $lastname = $_SESSION['lastname']; $firstname = $_SESSION['firstname']; $email = $_SESSION['email']; echo " <h4>Options for:</h4> $username <br /> <br /> First name: $firstname <br />Last name: $lastname <br /><br /><h3>Want to change your password:</h3><br /> <form action='?do=option' method='post'> Old password <input type='password' placeholder='Has to be between 5-15 digits' name='password' size='30' value='' /><br /> <br /> New Password<input type='password' placeholder='Has to be between 5-15 digits' name='newpass' size='30' value='' /><br /> <br /> Confirm new password <input type='password' placeholder='Has to be between 5-15 digits' name='passconf' size='30' value='' /><br /> <center></div><input type='submit' value='Submit'/></center></form>"; }else{ echo 'Please login to view your options!'; } $password = $_REQUEST['password']; $pass_conf = $_REQUEST['newpass']; $email = $_REQUEST['passconf']; $connect = mysql_connect("Host", "User", "Password"); if(!$connect){ die(mysql_error()); } //Selecting database $select_db = mysql_select_db("My Database", $connect); if(!$select_db){ die(mysql_error()); } //Find if entered data is correct $result = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'"); $row = mysql_fetch_array($result); $id = $row['id']; mysql_query("UPDATE users SET password='$newpass' WHERE username='$user'") ?> And i do know that i dont have a if(Empty($newpass)){ Die(Please fill out the new password) } Or any security on the others, but the problem just seems that it resets the password into nothing Hope i can get this fixed Best Regards William Pfaffe This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=353345.0 <?php
require_once('upper.php'); require_once('database.php'); echo $error_msg=''; if(isset($_POST['submit'])) { $LoginId=mysqli_real_escape_string($dbc,trim($_POST['LoginId'])); $Password1=mysqli_real_escape_string($dbc,trim($_POST['Password1'])); $Password2=mysqli_real_escape_string($dbc,trim($_POST['Password2'])); $Name=mysqli_real_escape_string($dbc,trim($_POST['Name'])); $Age=mysqli_real_escape_string($dbc,trim($_POST['Age'])); $BloodGroup=mysqli_real_escape_string($dbc,trim($_POST['BloodGroup'])); if(!isset($_POST['Sex'])) { echo 'Please enter Sex<br>'; } else{ $Sex= mysqli_real_escape_string($dbc,trim($_POST['Sex'])); } $Qualification=mysqli_real_escape_string($dbc,trim($_POST['Qualification'])); $ContactNumber=mysqli_real_escape_string($dbc,trim($_POST['ContactNumber'])); $Email=mysqli_real_escape_string($dbc,trim($_POST['Email'])); $Address=mysqli_real_escape_string($dbc,trim($_POST['Address'])); $AboutYourself=mysqli_real_escape_string($dbc,trim($_POST['AboutYourself'])); //$countCheck=count($_POST['checkbox']); //echo $countCheck; //$checkbox=$_POST['checkbox']; //$countCheck=count($checkbox); if(empty($LoginId)){echo 'Please enter Login Id';} elseif(empty($Password1)){echo 'Please enter Password';} elseif(empty($Password2)){echo 'Please confirm Password';} elseif($Password1!==$Password2){echo 'Password didn\'t match';} elseif(empty($Name)){echo 'Please enter Name';} elseif(empty($Age)){echo 'Please enter Age';} elseif(!isset($_POST['Sex'])){} elseif(empty($Qualification)){echo 'Please enter Qualification';} elseif(empty($ContactNumber)){echo 'Please enter Contact Number';} elseif(empty($Email)){echo 'Please enter Email';} elseif(empty($Address)){echo 'Please enter Address';} elseif(empty($AboutYourself)){echo 'Please enter About Yourself';} elseif(!isset($_POST['checkbox'])){ echo 'You have to register at least one activity.';} elseif(!isset($_POST['TermsAndConditions'])){ echo 'You have to agree all Terms and Conditions of Elite Brigade.';} else { require_once('database.php'); $query="select * from registration where LoginId='$LoginId'"; $result=mysqli_query($dbc,$query); if(mysqli_num_rows($result)==0) { $checkbox=$_POST['checkbox']; $countCheck=count($_POST['checkbox']); $reg_id=' '; for($i=0;$i<$countCheck;$i++) { $reg_id=$reg_id.$checkbox[$i].','; $query="insert into activity_participation (LoginId,Title,Date) values ('$LoginId','$checkbox[$i]',CURDATE())"; $result=mysqli_query($dbc,$query) or die("Not Connected"); } $query="insert into registration (LoginId,Password,Name,Age,BloodGroup,Sex,Qualification,ContactNumber,Email,Address,AboutYourself,Activity)values ('$LoginId'[B],SHA('$Password1'),[/B]'$Name','$Age','$BloodGroup','$Sex','$Qualification','$ContactNumber','$Email','$Address','$AboutYourself',',$reg_id')"; $result=mysqli_query($dbc,$query) or die("Not Connect"); echo ' Dear '.$Name.'.<br>Your request has been mailed to admin.<br>Your account is waiting for approval<br>'; $from= 'Elite Brigade'; $to='ankitp@rsquareonline.com'; $subject='New User Registration'; $message="Dear admin,\n\nA new user request for registration. Please check it out.\n\nRegards\nMicro"; mail($to,$subject,$message,'From:'.$from); //header('Location: index.php'); // header('Location: Registration.php'); } else { echo 'Dear '.$Name. ', <br> An account already exist with login-id<b> '.$LoginId.'</b> <br>Please try another login-id'; }} } ?> <html> <head> <script src="jquery-latest.js"></script> <script type="text/javascript" src="jquery-validate.js"></script> <style type="text/css"> * { font-family: Verdana; } label.error { color: white; padding-left: .5em; } p { clear: both; } .submit { margin-left: 12em; } em { font-weight: bold; padding-right: 1em; vertical-align: top; } </style> <script> $(document).ready(function(){ $("#commentForm").validate(); }); </script> </head> <body> <?php echo $error_msg; ?> <form action='<?php echo $_SERVER['PHP_SELF'];?>' id="commentForm" method='post'> <div class="registration_and_activity"> <table border="0" width="380"> <tr><td colspan="2"> <h3>New User?</h3></td></tr> <tr><td width="120"> <em>*</em>Enter Login id</td><td width="150"><input type='text' name='LoginId' minlength="4" value='<?php if(!empty($LoginId))echo $LoginId;?>' /></td></tr> <tr><td> <em>*</em>Enter Password</td> <td><head> <div id="divMayus" style="visibility:hidden">Caps Lock is on.</div> <SCRIPT language=Javascript> function capLock(e){ kc = e.keyCode?e.keyCode:e.which; sk = e.shiftKey?e.shiftKey:((kc == 16)?true:false); if(((kc >= 65 && kc <= 90) && !sk)||((kc >= 97 && kc <= 122) && sk)) document.getElementById('divMayus').style.visibility = 'visible'; else document.getElementById('divMayus').style.visibility = 'hidden'; } </SCRIPT> </HEAD> <input onkeypress='return capLock(event)' type='password' name='Password1' value='<?php if(!empty($Password1))echo $Password1;?>' /></td></tr> <tr><td> <em>*</em>Confirm Password</td><td><input type='password' name='Password2' value='<?php if(!empty($Password2))echo $Password2;?>' /></td></tr> <tr><td width="120"> <em>*</em>Enter Name</td> <td><input type='text' name='Name' value='<?php if(!empty($Name))echo $Name;?>' /></td></tr> <tr><td> <em>*</em>Enter Age</td><HEAD> <SCRIPT language=Javascript> function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } </SCRIPT> </HEAD> <td><INPUT onkeypress='return isNumberKey(event)' type='text' name='Age' value='<?php if(!empty($Age))echo $Age;?>'/></td></tr> <tr><td> <em>*</em>Enter Blood</td><td><input type='text' name='BloodGroup' value='<?php if(!empty($BloodGroup))echo $BloodGroup;?>' /></td></tr> <tr><td> <em>*</em>Enter Sex</td><td><input type='radio' name='Sex' style='width:16px; border:0;' 'value='Male' />Male <input type='radio' name='Sex' style='width:16px; border:0;' 'value='Female' />Female</td></tr> <tr><td> <em>*</em>Enter Qualification</td><td><input type='text' name='Qualification' value='<?php if(!empty($Qualification))echo $Qualification;?>' /></td></tr> <tr><td> <em>*</em>Contact Number </td><td><input onkeypress='return isNumberKey(event)'type='text' name='ContactNumber' value='<?php if(!empty($ContactNumber))echo $ContactNumber;?>' /></td></tr> <tr><td> <em>*</em>Enter Email</td><td><input type='text' name='Email'class="email" value='<?php if(!empty($Email))echo $Email;?>' /></td></tr> <tr><td> <em>*</em>Enter Address</td><td><input type='text' name='Address' value='<?php if(!empty($Address))echo $Address;?>' /></td></tr> <tr ><td > <em>*</em>About Yourself </td></tr> <tr><td colspan="2"><textarea rows='10' cols='40' name='AboutYourself' /><?php if(!empty($Address))echo $Address;?></textarea></td></tr> <tr><td> <?php echo" <tr><td colspan='2'><em>*</em><b>Select fields for which you want to register</b></td></tr>"; require_once('database.php'); $query="select * from activity"; $result=mysqli_query($dbc,$query); while($row=mysqli_fetch_array($result)){ $Title=$row['Title']; $ActivityId=$row['ActivityId']; echo "<tr><td>$Title</td>"; echo "<td><input type='checkbox' name='checkbox[]' value='$Title' style='width:14px; text-align:right;'/></td></tr>";//value=$ActivityId tells ActivityId variable extracts with name="checkbox" echo "<br/>"; } echo "<td><em>*</em><input type='checkbox' name='TermsAndConditions' style='width:14px; text-align:right;'/></td><td> I agree all <a href='TermsAndConditions.php'>Terms and conditions </a>of Elite Brigade</td></tr>"; echo "<tr><td colspan='2' align='center'><input type='submit' value='Register' name='submit' style='background:url(./images/button_img2.png) no-repeat 10px 0px; width:100px; padding:3px 0 10px 0; color:#FEFBC4; border:0;'/></td></tr><br>"; echo " </td></tr></table> </div> </form> </body> </html>"; require_once('lower.php'); ?> Hi Friends .... I encrypt user password by SHA('$Password') method but now i want to add "Forget Password Module" for which I need to decrypt it first before tell my user but I don't Know how to decrypt it. Please help me........ while($row = mysql_fetch_array($results, MYSQL_NUM)) { $total_price = $row["Computer_price"] + $total_price ; $total_items = $number_of_items = $number_of_items + 1; } This is the code and its telling em there is a parse error with line 16 which is the "while" line of code any suggestions at all? Thank you hi in a php file I assign a value to a tag. and with it make a condition for mysql command. but when run query and then using a form for sending some values to a function, all thin is work , but the vale of tag erased. when i trying to define this tag as global I see below errors. Code: [Select] Parse error: parse error, unexpected '=', expecting ',' or ';' in C:\Apache2\htdocs\bill\desktop\send_game.php on line 64 Hi im looking to set up a booking a taxi system for the local taxi firms in my area . I woudl be running it through a website where the user will log on choose where they want to go when etcetc these details will be sent to all the taxi companies in the area ( there are only about 5 companies) they will provides quotes such as time est price etc then the user will accept which ever quote they want. Now i know i need to proberbly store the details into a table then get the taxi companies to fill out the rest then provide the full details to the user to accept or decline but i dont know where to start i have all of the layouts ready but do i start by getting the user to enter the first details get them to be stored into a database then how would i get the companies to pick up the correct customer details any ideas? Or are there anys cripts out there that i can use at all Thank You hi i insert some values in a table, that goes well but right after the insert, i call the value of $matchidcheck, wich has just been inserted to the db correctly and it gives me the value of 0 ... in the $mes so it isnt forwarding correctly either how is this possible? $insertSite_sql3 = "INSERT INTO ffa_mapvotes (matchid,playerid,mapid,mapname) VALUES ($matchidcheck,$playerid,$vote3,'$vote3checker')"; $insertSite3= mysql_query($insertSite_sql3); $mes="$matchidcheck Vote Succesfull ... Please Wait ..."; return success($mes,'./ffacheckin.php?match=$matchidcheck'); if i replace the last line with return success($mes,'./ffacheckin.php?match=112'); it works ... I'm creating a script and having problems with the log in portion using sessions. Everything works fine when I set the sessions for the log in which is in the root directory. The problem arises when I try to create an admin area and cross from the user side to the admin side which is in a different directory of its own. I do an echo to check for the sessions in admin area and all are lost. /root <--sessions work 100% Click link to go to /root/admin <--- sessions are lost and yes all pages have session_start() Any advice would gladly be appreciated! Thanks Here is login code: <?php session_start(); include("admin/db/db_connect.php"); $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM members WHERE user_name='$myusername' and user_pass='$mypassword'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); $status = $rows['status']; $user_id = $rows['user_id']; if(($status!="") && ($status==0)){ $m="Your Account has not been activated or is suspended!"; $m = base64_encode($m); header("location:login.php?m=$m"); exit(); } $count=mysql_num_rows($result); if($count==1){ $_SESSION['myusername'] = $myusername; $_SESSION['myuser_id'] = $user_id; if($user_id == "1"){ $_SESSION['admin'] = $myusername . $user_id; } //echo $user_id . $myusername."<p></p>"; //echo $_SESSION['myusername'] . $_SESSION['myuser_id'] . $_SESSION['admin']; //exit(); $m="Login Successful!"; $m = base64_encode($m); header("location:members.php?m=$m"); } else { $m="Login Failed, Please Try Again!"; $m = base64_encode($m); header("location:login.php?m=$m"); } ?> That works fine for members area and other files in root: <?php session_start(); include("inc/vars.php"); include("admin/db/db_connect.php"); include("inc/page_header.php"); if(!isset($_SESSION['myusername'])){ header("location:login.php"); } ?> <?php $m = $_GET['m']; $m = base64_decode($m); ?> <?php include("inc/page_footer.php");?> But it doesn't for this script in admin: <?php session_start(); $log = $_SESSION['myusername']; $in = $_SESSION['myuser_id']; $key = $log . $in; echo "<p>-->". $log . $in ."<--</p>"; echo $key."<-- Key"; exit(); //testing if($_SESSION['admin'] !== $key){ header("location:/login.php"); } $ImageDirx = "../sopImages/"; $func = $_GET["func"]; $picid = $_GET["picid"]; $dothis = $_GET["dothis"]; if($func != "" && $picid != "" && $dothis != ""){ function DoDelete($picid,$dothis) { include ("../inc/vars.php"); include ("db/db_connect.php"); include ("admin_header.php"); $query ="SELECT * FROM listings WHERE picid='$picid'"; $result = mysql_query($query); $row = mysql_fetch_array($result); $delete = $row["imagefile"]; // Delete image from server & DATABASE //echo $ImagePth . $delete;exit(); $sql = "DELETE FROM listings WHERE picid='$picid'"; $result = mysql_query($sql); @unlink($ImagePth . $delete); } function DoStatusC($func,$picid,$dothis) { include ("../inc/vars.php"); include ("db/db_connect.php"); include ("admin_header.php"); if($func == hold){ $Nactive = "n"; } else{ $Nactive = "y";} $query ="SELECT * FROM listings WHERE picid='$picid'"; $result = mysql_query($query); $myrow = mysql_fetch_array($result); $picid = $myrow["picid"]; $active = $myrow["active"]; $sql ="UPDATE listings SET active='$Nactive' WHERE picid='$picid'"; $result = mysql_query($sql); } if($func == "delete"){ DoDelete($picid,$dothis); } else { DoStatusC($func,$picid,$dothis); } } if (empty($_GET["dothis"])) { shownew(); Die(); } else {$dothis = $_GET["dothis"];} if($dothis == "echonew"){shownew(); die();} elseif($dothis == "echoactive"){showactive(); die();} elseif($dothis == "echoall"){showall(); die();} elseif($dothis == "resetDB"){DoresetDB(); die();} // Retrieve all images from the db function showall() { include("../inc/vars.php"); include ("db/db_connect.php"); include ("admin_header.php"); $query = "SELECT * FROM listings ORDER BY id DESC"; $result = mysql_query($query); $num = mysql_num_rows($result); if ($num == "0") {print("No Results");include("admin_footer.php"); die();} if ($num < "20") {$Xwarning = "WARNING: There are not enough images for this script to work correctly.<br>";} print("<font color='red'>$Xwarning</font>"); print("<font color='blue'>$num</font> Image(s)<br>"); if($num > 0){ $i=0; echo ""; while($i < $num){ $id = mysql_result($result, $i, "id"); $owner_id = mysql_result($result, $i, "owner_id"); $picid = mysql_result($result, $i, "picid"); $imagename = mysql_result($result, $i, "imagename"); $imagefile = mysql_result($result, $i, "imagefile"); $active = mysql_result($result, $i, "active"); $query2 ="SELECT * FROM members WHERE user_id='$owner_id'"; $result2 = mysql_query($query2); $myrow2 = mysql_fetch_array($result2); $name = $myrow2["user_name"]; if ($active == "n") {$status = "Hold";} else {$status = "Active";} if ($active == "n") {$statusL = "<a href=\"inedx.php?func=allow&picid=$picid&dothis=echoall\">Click to Allow</a>";} else {$statusL = "<a href=\"index.php?func=hold&picid=$picid&dothis=echoall\">Click to Hold</a>";} echo "<table border=\"0\" cellspacing=\"1\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width= \"585\"> <tr><td width=\"237\"><img src='../i.php?src=/".$ImageDir."".$imagefile."&h=&w=150&zc=0'></td> <td width=\"341\" valign=\"top\"><b>Submitted By:</b> <a href=\"member.php?user_id=".$owner_id."\">". $name."</a><br><b>Website:</b> ".$website."<br><b>Image Name:</b> ".$imagename."<br><b>Status:</b> ".$status."<br><br><a href=\"index.php?func=delete&picid=$picid&dothis=echoall\">Delete</a> | ".$statusL."</td> </tr>\n</table><hr color=\"#0000FF\" align=\"left\" width=\"570\" size=\"1\">"; $i++; } echo ""; } include("admin_footer.php"); } function shownew() { // Retrieve all new images from the db include("../inc/vars.php"); include ("db/db_connect.php"); include ("admin_header.php"); $query = "SELECT * FROM listings WHERE active='n' ORDER BY id DESC"; $result = mysql_query($query); $num = mysql_num_rows($result); if ($num == "0") {print("No Results"); include("admin_footer.php"); die();} print("<font color='blue'>$num</font> Image(s)<br>"); if($num > 0){ $i=0; echo ""; while($i < $num){ $id = mysql_result($result, $i, "id"); $owner_id = mysql_result($result, $i, "owner_id"); $picid = mysql_result($result, $i, "picid"); $imagename = mysql_result($result, $i, "imagename"); $imagefile = mysql_result($result, $i, "imagefile"); $active = mysql_result($result, $i, "active"); $query2 ="SELECT * FROM members WHERE user_id='$owner_id'"; $result2 = mysql_query($query2); $myrow2 = mysql_fetch_array($result2); $name = $myrow2["user_name"]; if ($active == "n") {$status = "Hold";} else {$status = "Active";} if ($active == "n") {$statusL = "<a href=\"index.php?func=allow&picid=$picid&dothis=echonew\">Click to Allow</a>";} else {$statusL = "<a href=\"index.php?func=hold&picid=$picid&dothis=echonew\">Click to Hold</a>";} echo "<table border=\"0\" cellspacing=\"1\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width= \"585\"> <tr><td width=\"237\"><img src='../i.php?src=/".$ImageDir."".$imagefile."&h=&w=150&zc=0'></td> <td width=\"341\" valign=\"top\"><b>Submitted By:</b> <a href=\"member.php?user_id=".$owner_id."\">". $name."</a><br><b>Website:</b> ".$website."<br><b>Image Name:</b> ".$imagename."<br><b>Status:</b> ".$status."<br><br><a href=\"index.php?func=delete&picid=$picid&dothis=echonew\">Delete</a> | ".$statusL."</td> </tr>\n</table><hr color=\"#0000FF\" align=\"left\" width=\"570\" size=\"1\">"; $i++; } echo ""; } include("admin_footer.php"); } function showactive(){ // Retrieve all Active images from the db include("../inc/vars.php"); include ("db/db_connect.php"); include ("admin_header.php"); $query = "SELECT * FROM listings WHERE active='y' ORDER BY id DESC"; $result = mysql_query($query); $num = mysql_num_rows($result); if ($num == "0") {print("No Results");include("admin_footer.php"); die();} if ($num < "20") {$Xwarning = "WARNING: There are not enough images for this script to work correctly.<br>";} print("<font color='red'>$Xwarning</font>"); print("<font color='blue'>$num</font> Image(s)<br>"); if($num > 0){ $i=0; echo ""; while($i < $num){ $id = mysql_result($result, $i, "id"); $owner_id = mysql_result($result, $i, "owner_id"); $picid = mysql_result($result, $i, "picid"); $imagename = mysql_result($result, $i, "imagename"); $imagefile = mysql_result($result, $i, "imagefile"); $active = mysql_result($result, $i, "active"); $query2 ="SELECT * FROM members WHERE user_id='$owner_id'"; $result2 = mysql_query($query2); $myrow2 = mysql_fetch_array($result2); $name = $myrow2["user_name"]; if ($active == "n") {$status = "Hold";} else {$status = "Active";} if ($active == "n") {$statusL = "<a href=\"index.php?func=allow&picid=$picid&dothis=echoactive\">Click to Allow</a>";} else {$statusL = "<a href=\"index.php?func=hold&picid=$picid&dothis=echoactive\">Click to Hold</a>";} echo "<table border=\"0\" cellspacing=\"1\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width= \"585\"> <tr><td width=\"237\"><img src='../i.php?src=/".$ImageDir."".$imagefile."&h=&w=150&zc=0'></td> <td width=\"341\" valign=\"top\"><b>Submitted By:</b> <a href=\"member.php?user_id=".$owner_id."\">". $name."</a><br><b>Website:</b> ".$website."<br><b>Image Name:</b> ".$imagename."<br><b>Status:</b> ".$status."<br><br><a href=\"index.php?func=delete&picid=$picid&dothis=echoactive\">Delete</a> | ".$statusL."</td> </tr>\n</table><hr color=\"#0000FF\" align=\"left\" width=\"570\" size=\"1\">"; $i++; } echo "$warning"; } include("admin_footer.php"); } ?> http://content.screencast.com/users/DeviousDan/folders/Jing/media/a563187c-93fe-4ec7-b496-41e50554b639/2011-01-02_2220.png As you can see, I print_r the results array and it has a key of aim, I then try to access the aim value on line 44 and as you can see, it's an undefined Index. I've officially forgotten all basics of PHP, any fresh eyes wanna give some insight? Thanks. Ok I have NEVER had problem like this before. First of all, I am not that great with cookies or headers. But I know how to set cookies & sessions & how to use them. Any way, this is the most important feature & page on my app. Its for the register page, it sets a cookie that is needed to prevent fraud. I did the development of this script on my local server & this is my first time testing it on a real server. My issue is, I keep getting the damn headers already sent error; Code: [Select] Warning: Cannot modify header information - headers already sent by (output started at /../../..//mysite.com/admin/includes/linkmysql.php:2) in /../../../mysite.com/reg.php on line 36 I literally tried everything. I completely rewrote the page to work around this. I cannot stress enough how important this cookie is. I dont udnerstand. The php is b4 all the html, etc etc. There should be no other "headers being sent". Heres the code; <?php require_once 'is_email.php'; $result = is_email(@$email, true, true); if (isset($_POST['register_clicked']) && $_POST['register_clicked']==1) { $uname = $_POST['uname']; $upasswd = $_POST['passwd']; $email = $_POST['email']; if (!(strlen($uname) > 0 && strlen($uname) < 31)) echo '<td colspan="3" align="center" class="FormError"> USERNAME length must be between 1 and 30! </td>'; else if (!(strlen($upasswd) > 0 && strlen($upasswd) < 41)) echo '<td colspan="3" align="center" class="FormError"> PASSWORD length must be between 1 and 30! </td>'; else if ($upasswd != $_POST['passwdconf']) echo '<td colspan="3" align="center" class="FormError"> PASSWORD doesn\'t match! </td>'; else if (!is_email($email)) echo "<td colspan='3' align='center' class='FormError'>{$email} is not a valid email address! (result code $result)</td>"; else { include_once('admin/includes/linkmysql.php'); include('admin/includes/func.php'); if (!newuser($uname, $upasswd, $email)) echo "<td colspan='3' align='center' class='FormError'>Username already in use!</td>"; else { echo '<strong><font color="black">Registration Completed!</font></strong>'; $value = "no-delete"; setcookie("Muffins", $value, mktime (0, 0, 0, 12, 31, 2015)); #if (isset($_POST['autologin'])) #{ add_login($uname); $_SESSION['login_name'] = $uname; ?> <!--<script language="javascript" type="text/javascript"> window.location.href = "index.php?a=home"; </script> --> <?php } } } ?> <?php if (isset($_COOKIE['Muffins'])) { Header ('Location: http://mysite.com/index.php?a=noreg'); } ?> line 36 is obviously the line with the setcookie. I have no idea why it is referencing the include file, it has two lines of code that defines the mysql connections. This code is at the top of the page, before all the HTML etc. NO reason why it should be giving me header errors rigght!?? Im having the same issue with another page. I ban users thru setting a value in a mysql table, when the "system" notices the ban value is set, it redirects them to an account banned page using a header. BUT ITS THE SAME ******** THING!!!!! NEVER in my YEARS of coding have I ran into such AN ANNOYING & SENSELESS ISSUE! Sorry I am just SO frustrated, due to this I have not worked on this in days I pretty much gave up. I cannot launch this site that I have been working on for years without this working. THANK YOU FOR ALL YOUR HELP!!! Much appreciated. Hi- I've got a few simple forms on my site that get relayed over to our email server when the submit button is hit. The forms, in turn, get emailed to the predetermined recipients from that mail server. It's been working great for years, but we changed our mail server recently and didn't point the php.ini config to the new server and we've missed some form submissions for a few days (I know, I know). Looking at the PHP error log, I've got about 140 "PHP Warning: mail() [<a href='function.mail'>function.mail</a>]: SMTP server response: 530 5.7.1 Client was not authenticated in " entries, which tells me we missed 140 form submissions. My question is: is there any way to retrieve these form submissions? Are they sitting someplace on my site that I can extract them from? Do they literally just disappear if they can't get to the SMTP server?
Many thanks in advance for any responses!
kinda new in php so hope somebody can help me im about to get mad with this i have 2 pages index.htm and list_tbl.php in the index.htm i have a textbox so the customers write what they want to find in my site with a search button like this : <form id="form1" name="form1" method="post" action="list_tbl.php" target="_blank"> in the list_tbl.php is like this <?php $srch = $_POST['prod_search']; $se = "%"; '$all' = $se.$srch.$se; $msj="You look for : "; $msj2=$mensaj.$srch; $regis=" your search match :"; $regis2=" Items"; $conn = mysql_connect('localhost','root','pass') or trigger_error("tbl_die", E_USER_ERROR); . . . . . works fine if i write 4 example "blue metal" in the index the php page get me You Look for blue metal Your search match XX items but if the filter get more then 1 page when i clik in the next link the filter is gone the "blue metal" string is lost and i have all the items in the table why the $_post Value is lost after paginate??? 1000 TNX Hello all, I just wrote a php website to communicate with a database and it has a login based on the users email and password, they login on the first page and then the php checks for every page they visit if they indeed logged in before and not just found out what php file to open to get where they want to be. For this I used session variables to store both e-mail and password. The login info gets posted from the 1st(login) site to the 2nd site where it is checked for the first time, after that the login info isn't posted to the next page anymore, but just checked, this works for the 3rd page but when the user hits for the 4th page the variables are lost(I can't echo them either). However if I'd go from the 2nd page directly to the 4th page the page will load, however the 5th will then get my security-msg. So offcourse, I am wondering how this might have happened and how to fix this problem, here's some of the code I wrote: This is the check for the logininfo: <?php include('SessionStart.php'); include('logindata.php'); $db = mysql_connect($host, $user, $pw); if (!$db) { echo "<br />Helaas, u heeft geen verbinding met de database."; exit(); } else { mysql_select_db("teammanagementtool", $db); $sql24 = "SELECT * FROM leidinggevenden"; $allesarray = mysql_query($sql24); $i = 0; while ($mails = mysql_fetch_array($allesarray)) { $mailtjes[$i] = $mails['lg_mailadres']; $i = $i+1; } echo "...".$_SESSION['sessie']['email']."...".$_SESSION['sessie']['password']."...".$session_name."..."; if (in_array($_SESSION['sessie']['email'],$mailtjes)) { $sql25 = "SELECT lg_wachtwoord FROM leidinggevenden WHERE lg_mailadres = '".$_SESSION['sessie']['email']."'"; $pass = mysql_query($sql25); $pasje = mysql_fetch_array($pass); if ($_SESSION['sessie']['password'] != $pasje['lg_wachtwoord']) { echo "<script>alert('U bent hier op incorrecte manier terecht gekomen!');</script>"; echo "<meta http-equiv='refresh' content='0;URL=index.php' />"; exit(); } else if ($_SESSION['sessie']['password'] = "" || $_SESSION['sessie']['email'] = ""){ echo "<script>alert('U bent hier op incorrecte manier terecht gekomen!');</script>"; echo "<meta http-equiv='refresh' content='0;URL=index.php' />"; exit(); } else { } } else { echo "<script>alert('U bent hier op incorrecte manier terechtgekomen!');</script>"; echo "<meta http-equiv='refresh' content='0;URL=index.php' />"; exit(); } ?> And this is the code in my SessionStart.php: <?php $session_name = 'sessie'; $session_exp_time = 10000 ; $previous_name = session_name($session_name); ini_set('session.gc_maxlifetime', $session_exp_time); ini_set('session.gc_probability', '1'); ini_set('session.gc_divisor', '1000'); ini_set('session.name', $session_name); ini_set('session.cookie_domain', ''); ini_set('session.cookie_lifetime', 0 ); session_set_cookie_params($session_exp_time, '/', ''); session_start(); if (isset($_COOKIE[$session_name])) setcookie($session_name, $_COOKIE[$session_name], 2147483647 , ''); ?> the includes are at the start of all of my pages, I only do a session_unset() at my index.php(the login page). and my 2nd page gets: $_SESSION['sessie']['email'] = $_POST['email']; $_SESSION['sessie']['password'] = $_POST['password']; from the login. I could really use some help here, thanks in advance. Hello all, i'm attempting to implement i18n into my project. so I read some tutorials, copied some code and eventually made the following: Code: [Select] /** * applyMultiLingual uses the gettext module from PHP to support multilingual * @param Array $settings */ private static function applyMultiLingual($settings){ /* init global config */ bindtextdomain(self::$project_name,Config::path('i18n')); bind_textdomain_codeset(self::$project_name, 'UTF-8'); textdomain(self::$project_name); if(!array_key_exists('enabled', $settings) || $settings['enabled'] == false){ //initiate default (english) putenv("LC_MESSAGES=en_EN"); setlocale(LC_MESSAGES,'en_EN'); } else{ if(Session::language() === null){ //initiate custom if($settings['default'] == 'auto'){ locale::acceptFromHttp($header); } else{ putenv("LC_MESSAGES=".$settings['default']);setlocale(LC_MESSAGES,$settings['default']); } } else{ putenv("LC_MESSAGES=".Session::language()); setlocale(LC_MESSAGES,Session::language()); } } } The code is (imo) pretty readable, so it sets the textdomain to "project1", and the current language to en_EN. if should search for the translations in DOC_ROOT/i18n/ now, it returns the text between the _(); functions, but I get no translation files in said directory, and I also have no clue how to accomplish this. so what I want to accomplish is this: enable use of function _(), which saves all translations in a folder i18n, and subfolder LOCALE_CODE (ex. DOC_ROOT/i18n/en_EN/messages.po). what am I doing wrong, and how can I fix it? thanks to any who can help, and if more info is needed, ask and you shall receive. I'm trying to get back into PHP, but I'm running into some trouble. I'm creating a little script that scraps data from a page and then displays it elsewhere. (I'm actually going to insert it into a database, but for now, just trying to display it! There's two pages I'm scraping from. This scrapes the list of players from one web page: $html = file_get_contents("http://www.somesite.com/players.php?search=who"); preg_match_all( '/<td width=\'33\.3333333333\%\'><a href=\'\/players.php\?lookup=.*?\'>(.*?)<\/a>/', $html, $players, PREG_SET_ORDER ); That matches fine. Then for each name I want to scrape another page that has more information about each individual player: foreach ($players as $player) { $html2 = file_get_contents("http://www.somesite.com/players.php?lookup=$player"); preg_match_all( '/<font size=\'\+1\'><strong>.*?<\/font><\/strong>/', $html2, $longName, PREG_SET_ORDER ); preg_match_all( '/Race<\/font><\/td><td><font size=\'\-1\'>.*?<\/font>/', $html2, $race, PREG_SET_ORDER ); preg_match_all( '/Citizenship<\/font><\/td><td><font size=\'\-1\'>.*?<\/font>/', $html2, $citizenship, PREG_SET_ORDER ); preg_match_all( '/Level<\/font><\/td><td><font size=\'\-1\'>.*?<\/font>/', $html2, $level, PREG_SET_ORDER ); echo $longName[0][0]; echo ("<br>"); $rac = implode("", $race[0]); $newrace = substr($rac, 4, -1); echo $newrace; echo ("<br>"); $cit = implode("", $citizenship[0]); $newcit = substr($cit, 11, -1); echo $newcit; echo ("<br>"); $lev = implode("", $level[0]); $newlevel = substr($lev, 5, -1); echo $newlevel; echo ("<br>"); } This does not work. I get Warning: implode() [function.implode]: Invalid arguments passed in /my/path/names.php on line <three implode lines> and I get NO echos except for the break lines. HOWEVER, if I just use this code outside of a loop, i.e. I just do $html2 = file_get_contents("http://www.somesite.com/players.php?lookup=MyPlayerName"); it works perfectly. I'm newb at coding, so I can't even figure out what data it is or is not getting in the iteration, and why it's not displaying/getting it when it's looped through each name as opposed to when it works perfectly when I input a single name in the file_get_contents. Can anyone see errors in how I'm going about this or suggest some checks to put in to help figure out what the heck is going wrong? Thanks much for any help. I have over 230 files plus 39 directories ( 3.5Mb ) in my public_html directory and I am looking for where I specified/declared the contents of a variable! I can't for the life of me remember in which web page/directory I set up the contents of that run time variable. ( It was three years ago! ) Can anyone advise me how find that data variable ( Its called $depositrules )? say if I had a black page with a background or something simple and it had no content except for a link called "about us" and I wanted that link to be located at the bottom left side of the page but since it has no content its stuck up the top unless <br> or <p> is introduced. how could this be done without spamming <br /><p><br /> untill im happy with its location and if content is added it gets boosted down further with a massive gap >< |