Jump to content

No error again..


dudejma

Recommended Posts

This code isn't working.. Again. It's a different code, same problem. It's not the same problem as the last time though. Can you find anything wrong with this code? Thanks. (Probably AyKay or Pikachu.)

 

<?php

require 'include/sql.php';

$random = $_GET['code'];

$sql = "SELECT * FROM temp_pass WHERE random='$random'";

$result = mysql_query($sql)
or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error());



if (isset($_POST['submit'])) {

while ($row = mysql_fetch_array($result)) {

$pilotid = $row['pilotID'];

$newPass = md5($_POST['password']);

$sql2 = "UPDATE users WHERE pilotID='$pilotid'";

$result2 = mysql_query($sql2)
or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error());

$sql3 = "DELETE FROM temp_pass WHERE pilotID='$pilotid'";

$result3 = mysql_query($sql3)
or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error());

header("Location: login.php");
}
}
?>

Link to comment
Share on other sites

I found some errors and fixed them but still nothing. Here's the updated code:

 

<?php

require 'include/sql.php';

$random = $_GET['code'];

$sql = "SELECT * FROM temp_pass WHERE random='$random'";

$result = mysql_query($sql)
or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error());



if (isset($_POST['submit'])) {

while ($row = mysql_fetch_array($result)) {

$pilotid = $row['pilotID'];

$newPass = md5($_POST['password']);

$sql2 = "UPDATE users SET password='$newPass' WHERE pilotID='$pilotid'";

$result2 = mysql_query($sql2)
or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error());

$sql3 = "DELETE FROM temp_pass WHERE pilotID='$pilotid'";

$result3 = mysql_query($sql3)
or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error());

header("Location: login.php");
}
}
?>

Link to comment
Share on other sites

well what exactly is happening here, i'm assuming that you aren't receiving any errors?

I also assume that your error_reporting is set to E_ALL

offhand I would think that it has something to do with your connection if your queries are not working properly...however an error would be triggered if that were the case...

Link to comment
Share on other sites

I can see several things with your code.

 

1. Not checking to see if $_GET['code'] exists and not planing for when it doesn't

2. creating an unnecessary mysql_query before if (isset($_POST['submit'])) { ...

3. this: $sql2 = "UPDATE users WHERE pilotID='$pilotid'"; is supposed to update what?

4. You have most of the code in a while loop but at the end of the first loop you do this: header("Location: login.php");

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.