NameSilo

Php help

Spacemail by SpaceshipSpacemail by Spaceship
Watch

Halbarad

Established Member
Impact
0
Hi,

i am trying to learn PHP and no i have managed to create member system with memberlist with help. And now i want to add a function that allows members to edit their information.

I tried it with this code but it does not work at all:
please help me out a bit!
PHP:
<?php
session_start(); 

if (!empty($_POST[username]))
{
	if ($_POST[password] != $_POST[password2])
		exit("Error - Passwords don't match. Please go back and try again.");

	require_once("connect.php");

	$query = mysql_query("update set members 
	(province, kingdom, email, msn, password)
	$affected_rows = $sql->id = $_SESSION[id];
	VALUES	(,'$_POST[province]','$_POST[kingdom]','$_POST[email]','$_POST[msn]','$_POST[password]')")

	or die ("Error - Couldn't edit account.");
	
 include("header.inc"); 
	echo "You have succesfully edited your account!<br /><br />
		Please login <a href='login.php'><b>here</b></a>.";
 include("footer.inc"); 
	exit();
}

?>


<?php include("header.inc"); ?>		<form action="account.php" method="post">
			<table width="75%" align="center" cellpadding="3" cellspacing="1" style="border: 5px solid #FFFFFF">
				<tr>
					<td width="100%" style="font-family: verdana; font-size: 10px"><b>edit your account</b></td>
				</tr>
				<tr>
					<td width="100%" style="font-family: verdana; font-size: 10px"><label>Province Name: <br /><input type="text" name="province" size="20" value="<? echo $_POST[province]; ?>"></label></td>
				</tr>
				<tr>
					<td width="100%" style="font-family: verdana; font-size: 10px"><label>Kingdom Coordinates: <br /><input type="text" name="kingdom" size="20" value="<? echo $_POST[kingdom]; ?>"></label></td>
				</tr>
				<tr>
					<td width="100%" style="font-family: verdana; font-size: 10px"><label>Email: <br /><input type="text" name="email" size="20" value="<? echo $_POST[email]; ?>"></label></td>
				</tr>
				<tr>
					<td width="100%" style="font-family: verdana; font-size: 10px"><label>MSN: <br /><input type="text" name="msn" size="20" value="<? echo $_POST[msn]; ?>"></label></td>
				</tr>
				<tr>
					<td width="100%" style="font-family: verdana; font-size: 10px"><label>Password: <br /><input type="password" name="password" size="20" value="<? echo $_POST[password]; ?>"></label></td>
				</tr>
				<tr>
					<td width="100%" style="font-family: verdana; font-size: 10px"><label>Verify Password: <br /><input type="password" name="password2" size="20" value=""></label></td>
				</tr>
				<tr>
					<td width="100%" style="font-family: verdana; font-size: 10px"><input type="submit" value="Edit!"></td>
				</tr>
			</table>
		</form>
<?php include("footer.inc"); ?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
PHP:
$query = mysql_query("update set members
    (province, kingdom, email, msn, password)
    $affected_rows = $sql->id = $_SESSION[id];
    VALUES    (,'$_POST[province]','$_POST[kingdom]','$_POST[email]','$_POST[msn]','$_POST[password]')")

Check the syntax of that ;) You declare a variable right in the middle of an SQL query! D-:
 
0
•••
you mean this line?
$affected_rows = $sql->id = $_SESSION[id];
 
0
•••
Yes. You can't declare a variable in a MySQL query.
 
0
•••
but this can not be the problem cuz if i put it outside the MySQL query it still doesnt work.

any other suggestions
 
0
•••
Why is there a comma in "VALUES(," .... that should not be there.
 
0
•••
PHP:
$affected_rows = $sql->id = $_SESSION[id];
$query = mysql_query("update set members
    (province, kingdom, email, msn, password)
    VALUES ('$_POST[province]','$_POST[kingdom]','$_POST[email]','$_POST[msn]','$_POST[password]')");
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back