Jump to content

Recommended Posts

Hi,

 

im creating a user script, and im having trouble populating a field with php.

 

Heres my structure!

 

<?php
//Admin Functions
include("config.php");


/**
* Displays the user and allows you to edit them
*/
function editUser($user) {
$sql = "SELECT * FROM `users` WHERE `username` = '$user'";
$query = mysql_query($sql) or die(mysql_error());
while ($fetch = mysql_fetch_array($query))
{
$form  = '<form name="Edit" method="POST" action="'.$_SERVER['PHP_SELF'].'">';
$form .= '<h3><b>Edit User -</b></h3><br />';
$form .= 'Username: <input type="text" name="user" value="$fetch['username']"/><br />';
$form .= 'Password: <input type="password" name="pass" value="$fetch['password']"/><br />';
$form .= 'Email: <input type="text" name="email" value="$fetch['email']"/><br />';
$form .= '<input type="submit" name="user" value="Submit"/>';
$form .= '</form>';
echo $form;	

} 
}

function selectUser() {
$form  = '<form name="Edit" method="POST" action="'.$_SERVER['PHP_SELF'].'">';
$form .= '<h3><b>Edit User -</b></h3><br />';
$form .= 'Username: <input type="text" name="user" value=""/><br />';
$form .= '<input type="submit" name="edit" value="Submit"/>';
$form .= '</form>';
}

function deleteUser() {

}

function siteConfig() {

}
?>

 

 

Parse error: syntax error, unexpected T_STRING in C:\wamp\www\php\users\adminfunctions.php on line 16

 

Thats what i keep getting and im not quite sure how to fix it, it has something todo with the value field in the form.. but i dont know what else to do.

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/98474-html-value-and-php/
Share on other sites

You cannot use variables within single quotes,:

	$form .= 'Username: <input type="text" name="user" value="$fetch['username']"/><br />';
$form .= 'Password: <input type="password" name="pass" value="$fetch['password']"/><br />';
$form .= 'Email: <input type="text" name="email" value="$fetch['email']"/><br />';

You should do:

	$form .= 'Username: <input type="text" name="user" value="'.$fetch['username'].'"/><br />';
$form .= 'Password: <input type="password" name="pass" value="'.$fetch['password'].'"/><br />';
$form .= 'Email: <input type="text" name="email" value="'.$fetch['email'].'"/><br />';

Link to comment
https://forums.phpfreaks.com/topic/98474-html-value-and-php/#findComment-503946
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.