SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old August 28th, 2002, 03:42 AM
alsaffar alsaffar is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 58 alsaffar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Form Problems

Hi there,

I have a form for updating the user profile:

<form method="post" action="UserCP.php">
<input name="FirstName" value="<? echo "$FirstName"; ?>">
<input name="Password">
<input type="submit">
<input type="reset">
</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 = "UPDATE Users
SET FirstName = '$FirstName'
WHERE UserID = '$UserID' ";

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 "UserName: $HTTP_COOKIE_VARS[CkUserName]";
echo "Password: $HTTP_COOKIE_VARS[CkPassword]";

$Query = "UPDATE Users SET Password = '$NewPassword'
WHERE UserID = '$UserID' ";
setcookie ("CkPassword", $NewPassord, time()+14400, "/", ".mydomain",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?

Reply With Quote
  #2  
Old August 28th, 2002, 08:38 AM
CmdrDats CmdrDats is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: <br><img src='http://www.dats.co.za/icon.gif'>
Posts: 269 CmdrDats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to CmdrDats Send a message via AIM to CmdrDats Send a message via Yahoo to CmdrDats
RE: Form Problems

Q1: To clear the fields :
php Code:
Original - php Code
  1.  
  2. <form method="post" action="UserCP.php">
  3. <input id=FirstName name="FirstName" value="<? echo "$FirstName"; ?>">
  4. <input id=Password name="Password">
  5. <input type="submit">
  6. <input type="button" onclick="resetForm()">
  7. </form>
  8. <script language=javaScript>
  9.  function resetForm() {
  10.   document.all.FirstName.value = "";
  11.   document.all.Password.value = "";
  12.  }
  13. </script>

I am unsure how compatible this is with netscape, but it should work fine in IE.

Q2: You could do something like :
php Code:
Original - php Code
  1. <?
  2. $set = "FirstName='$FirstName'";
  3. if ($Password) {
  4.  $set .= ", Password='$Password'"
  5. }
  6. $qry = "UPDATE USERS SET $set WHERE UserID=$UserID";
  7. ?>


Q3: Use ob_start() at the top of your script to enable output buffering.. either that or edit your php.ini and set the output_buffering to on

---

Hope that helps

Reply With Quote
  #3  
Old August 28th, 2002, 10:21 PM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: RE: Form Problems


this should work with netscape/mozilla as well...

php Code:
Original - php Code
  1.  
  2. <form method="post" action="UserCP.php" [b]name="user_form"[/b]>
  3. <input id=FirstName name="FirstName" value="<? echo "$FirstName"; ?>">
  4. <input id=Password name="Password">
  5. <input type="submit">
  6. <input type="button" onclick="resetForm()">
  7. </form>
  8. <script language=javaScript>
  9.  function resetForm() {
  10.   document.[b]user_form[/b].FirstName.value = "";
  11.   document.[b]user_form[/b].Password.value = "";
  12.  }
  13. </script>


Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Form Problems


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway