Jump to content

Weird things a happening in my script


pjheliking

Recommended Posts

I have a password reset form pretty basic but heres the weird thing it will sometimes work then not it goes back and forth. could you please have a wee look and see if there is anything i am missing or needing to shed (me = novice :P)

<?php
session_start();  
session_register("sessUsername");
$sessUsername = $HTTP_POST_VARS['username'];
?>
<? 
require_once('../../Connections/gimmiegimmie.php');
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
 $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

 $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 switch ($theType) {
   case "text":
     $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
     break;    
   case "long":
   case "int":
     $theValue = ($theValue != "") ? intval($theValue) : "NULL";
     break;
   case "double":
     $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
     break;
   case "date":
     $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
     break;
   case "defined":
     $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
     break;
 }
 return $theValue;
}
}

$maxRows_passretrieval = 10;
$pageNum_passretrieval = 0;
if (isset($_GET['pageNum_passretrieval'])) {
 $pageNum_passretrieval = $_GET['pageNum_passretrieval'];
}
$startRow_passretrieval = $pageNum_passretrieval * $maxRows_passretrieval;

$colname_passretrieval = "-1";
if (isset($_SESSION['sessUsername'])) {
 $colname_passretrieval = $_SESSION['sessUsername'];
}
mysql_select_db($database_thebar, $thebar);
$query_passretrieval = sprintf("SELECT * FROM bar33userdetails WHERE emailaddress = %s", GetSQLValueString($colname_passretrieval, "text"));
$query_limit_passretrieval = sprintf("%s LIMIT %d, %d", $query_passretrieval, $startRow_passretrieval, $maxRows_passretrieval);
$passretrieval = mysql_query($query_limit_passretrieval, $thebar) or die(mysql_error());
$row_passretrieval = mysql_fetch_assoc($passretrieval);

if (isset($_GET['totalRows_passretrieval'])) {
 $totalRows_passretrieval = $_GET['totalRows_passretrieval'];
} else {
 $all_passretrieval = mysql_query($query_passretrieval);
 $totalRows_passretrieval = mysql_num_rows($all_passretrieval);
}
$totalPages_passretrieval = ceil($totalRows_passretrieval/$maxRows_passretrieval)-1;
?>
<?php



// My Details

$email = $row_passretrieval['emailaddress'];

$pass = $row_passretrieval['password'];


// The subject


$subject = " Pasword Reminder";

// Grab Details

//no dets to grab continue

// The message

$message = "*****DONOT REPLY TO THIS MESSAGE AS THE EMAIL ADDRESS IS UNMANNED*****\n\n Password retrieval details for email address ".$email." \n\n Password = ".$pass." \n\n We recommend that you change your password to something more memorable you can do this in your settings when you log in.";



mail($email, $subject, $message, "From:Password Reseter <[email protected]>");

?>
<? 
$email = $row_passretrieval['emailaddress'];
header ("Location: confirm.php?process=lostpass&email=".$email."")
?>

 

any help will be greatly appreciated ma thanka u

Link to comment
https://forums.phpfreaks.com/topic/119045-weird-things-a-happening-in-my-script/
Share on other sites

That code seems really old.

 

Use $_POST and not $HTTP_POST_VARS (it's deprecated - http://pt.php.net/manual/en/reserved.variables.post.php)

 

 

From the manual: Use of $_SESSION is preferred, as of PHP 4.1.0

 

So you should use $_SESSION['sessUsername'] instead of the session_register function.

 

Why would you open a php tag and then close to just open another php tag? And why use both <? and <?php ?

 

As for your errors, either use a debugger or put some echoes in the code.

 

 

I changed what you said and still no joy im gonna get a debugger now ... regarding closing to open thats just pure lazyness on my part as i copy an paste most things i do make an attempt once and a while to sort through the code to make it better... and the <? and <?php copied and pasted and it really depends on how i feel when i wake up lol. thnx for tips

Yeah the problem were probably not in those functions but since you were going to change the code you might as well alter those.

Also, try to set the error level to E_ALL it might catch something we are not seeing.

 

And try and organize the code using tab, having:

 

 return $theValue;

}

}

 

Does not look good

 

no need to be nasty just cause u all prob know what your doing but i only started into php 2 weeks ago and all i was asking is there something im missing and as i said it has worked just dont know why it isnt now

 

You aren't doing php your playing around in dreamweaver big difference

Archived

This topic is now archived and is closed to further replies.

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