0

am writing an sql statement that can change the username and password but it is not working this is the code on line 19


$sql = "UPDATE login SET
username= newusername('$_POST'),password=newpassword('$_POST)
WHERE username = '$_POST',password='$_POST";

this is the error

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\ELIZA\passchange.php on line 19

assit to troubleshot.

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by gikonyo
0

What is

newusername('$_POST['newusername']');

is it a function?

Ok try this.

$username = $_POST['username'];
$password = $_POST['password'];
$newusername = $_POST['newusername'];
$newpassword = $_POST['newpassword'];
$sql = "UPDATE login SET
username= '$newusername', password='$newpassword' 
WHERE username = '$username', password='$password'";

Edited by mahavir123: n/a

0

thanks the error is gone but once the form for changing username and password is submitted a blank page results

this is the full code.

<?php


$con = mysql_connect("localhost","root","");
if (!$con)
{ 
die ('could not connect: '.mysql_error());
}

mysql_select_db("narok", $con);

$username= $_POST['username'];
$password=$_POST['password'];
$newusername= $_POST['newusername'];
$newpassword=$_POST['newpassword'];

//updates the table with the new password               
$username = $_POST['username'];
$password = $_POST['password'];
$newusername = $_POST['newusername'];
$newpassword = $_POST['newpassword'];
$sql = "UPDATE login SET
username= '$newusername', password='$newpassword'
WHERE username = '$username', password='$password'"; 
    $result = @mysql_query($sql, $connection) or die(mysql_error());

//sends the user to their redirect to
    header("Location:changepassword.php");
    exit;
?>

what could be missing

Edited by mike_2000_17: Fixed formatting

0

I think blank page results because there is nothing to print on this page. You can do something like:

if($result)
{
echo "success";
}
else
{
echo "failure";
}

otherwise on changepassword.php check if something mentioned.

What you can do is:
header("Location:changepassword.php?msg=$msg");

where $msg=success or failure.

So, it would be like:

if($result)
{
$msg= "success";
}
else
{
$msg= "failure";
}

header("Location:changepassword.php?msg=$msg");

On changepassword.php page,
get the msg value and print it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.