Welcome to Dream.In.Code
Become a PHP Expert!

Join 136,933 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,855 people online right now. Registration is fast and FREE... Join Now!




retaining values on form after button click

 
Reply to this topicStart new topic

retaining values on form after button click

samn84
17 Mar, 2008 - 01:01 AM
Post #1

New D.I.C Head
*

Joined: 21 Feb, 2008
Posts: 41

i have made a form which adds an employee.if the user makes a mistake like typing a 8 digit number instead of 7 digit number then i call the same form which retains his/her previous values and gives an error message.all works fine apart from that if there is a space in between user words like name=Charlie brown then upon error wen page is shown again with previously typed values,it shows Charlie only.if some one can tell me how o get the space and the other half name back in the same txt field.

code is like this:

CODE

@$name=$_POST['name'];
@$phone=$_POST['phone'];


*edit* code.gif
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Retaining Values On Form After Button Click
17 Mar, 2008 - 01:06 AM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,495



Thanked: 66 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(PsychoCoder @ 9 Mar, 2008 - 12:20 AM) *

Use the urldecode function available to you in PHP


php

$name = urldecode($_REQUEST['name']);
$company = urldecode($_REQUEST['company']);
echo "name: ".$name;
echo "company: ".$company;


User is online!Profile CardPM
+Quote Post

samn84
RE: Retaining Values On Form After Button Click
17 Mar, 2008 - 01:25 AM
Post #3

New D.I.C Head
*

Joined: 21 Feb, 2008
Posts: 41

i did this but thats not the problem........rather wen i get them again in a variable and print dem normally,values are shown but wen i wna get them printed in the txt box,that is where they are printed till the space,nofnk afta dat.

this is wa id o to get em prntd in txt box:

CODE

@$name=$_POST['name'];

<input type="text" name="name" size=24 value=<? echo $name;?>>


**EDIT** code.gif
User is offlineProfile CardPM
+Quote Post

thehat
RE: Retaining Values On Form After Button Click
17 Mar, 2008 - 02:02 AM
Post #4

D.I.C Head
Group Icon

Joined: 28 Feb, 2008
Posts: 217


Dream Kudos: 100
My Contributions
Try it with speech marks round your php statement, like this:

CODE

<input type="text" name="name" size=24 value="<? echo $name; ?>">


This post has been edited by thehat: 17 Mar, 2008 - 02:03 AM
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Retaining Values On Form After Button Click
17 Mar, 2008 - 02:05 AM
Post #5

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,495



Thanked: 66 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(thehat @ 17 Mar, 2008 - 03:02 AM) *

Try it with speech marks round your php statement, like this:

Yup, you've got to break the statement with the quote marks. For future reference, if you had posted all of the code before hand...

Also, please be sure to use code brackets.

code.gif
User is online!Profile CardPM
+Quote Post

samn84
RE: Retaining Values On Form After Button Click
18 Mar, 2008 - 08:59 PM
Post #6

New D.I.C Head
*

Joined: 21 Feb, 2008
Posts: 41

fanx man!!!it wrkd.
User is offlineProfile CardPM
+Quote Post

andrewvw
RE: Retaining Values On Form After Button Click
18 Mar, 2008 - 09:01 PM
Post #7

New D.I.C Head
Group Icon

Joined: 27 Jan, 2008
Posts: 28


Dream Kudos: 50
My Contributions
lol i love to see people helping people =) lol NOW SOMEONE GO HELP ME LOOK AT MY TOPIC!!!! lol jp just bored
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 10:42PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month