Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form Problems

Status
Not open for further replies.

alsaffar

Programmer
Oct 25, 2001
165
KW
Hi there,

I have a form for updating the user profile:

<form method=&quot;post&quot; action=&quot;UserCP.php&quot;>
<input name=&quot;FirstName&quot; value=&quot;<? echo &quot;$FirstName&quot;; ?>&quot;>
<input name=&quot;Password&quot;>
<input type=&quot;submit&quot;>
<input type=&quot;reset&quot;>
</form>

Q1. The first problem is when I view one of the input fields with a value like FirstName, the value will be inserted inside the input field, so when I try to hit the reset button, it's not working! Well, if it has to be this way, can I change the action of the reset button so it acts like a link to another page?

Q2. Look to the following code:

$Query = &quot;UPDATE Users
SET FirstName = '$FirstName'
WHERE UserID = '$UserID' &quot;;

I want to insert a condition inside the Query so if the user fill the Password input field, then the $Password will be inserted in the Query. Otherwise, I dont want to update the password field with an empty value, How can I do it? or the solution is I have to make 2 seperate queries for both conditions? If this is the way, then its really a pain in the neck if I have 10 conditions!!

Q3. If a code is simmilar to the follwoing:

echo &quot;UserName: $HTTP_COOKIE_VARS[CkUserName]&quot;;
echo &quot;Password: $HTTP_COOKIE_VARS[CkPassword]&quot;;

$Query = &quot;UPDATE Users SET Password = '$NewPassword'
WHERE UserID = '$UserID' &quot;;
setcookie (&quot;CkPassword&quot;, $NewPassord, time()+14400, &quot;/&quot;, &quot;.mydomain&quot;,0);

And when I run the code, its not accepted cause there is an output before the setcookie! Ok, anyway to make my setcookie works without changing the echo location to be down the setcookie, cause my code is too much complicated to change the place of the echo, if its imposible to avoid this, any other idea how can I change the cookie contents when the user change his password?
 
Q2:
if($Password!=&quot;&quot;){
$Query = &quot;UPDATE Users
SET FirstName = '$FirstName'
WHERE UserID = '$UserID' &quot;;
}



Rick if(($question==&quot;has been bugging me&quot;
AND $answer==&quot;fixed the problem&quot;) OR $answer==&quot;really good post&quot;){
print(&quot;Star&quot;);
}else{
print(&quot;Thanks.&quot;);
}
 
Q1:
If you can't find a way to change $FirstName to &quot;&quot; in Javascript, you can do this:

<form method=&quot;post&quot; action=&quot;UserCP.php&quot;>
<input name=&quot;FirstName&quot; value=&quot;<? echo &quot;$FirstName&quot;; ?>&quot;>
<input name=&quot;Password&quot;>
<input type=&quot;submit&quot;>
<input type=&quot;button&quot; onClick=&quot;location.href=location.href+'?FirstName='&quot;>
</form>

Rick if(($question==&quot;has been bugging me&quot;
AND $answer==&quot;fixed the problem&quot;) OR $answer==&quot;really good post&quot;){
print(&quot;Star&quot;);
}else{
print(&quot;Thanks.&quot;);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top