Page 1 of 1
This damn code wont work......
Posted: Fri Dec 13, 2002 11:21 pm
by GTCobra
Hello PHP friends, I am new to this forum. I am having great problems with my code. I can't figure for the life of me what the heck is going on. I have the form set up correctly and I think that php is correct too. So I try to fill out the form by myself and decide I don't want to fill in a few things. The next page pops up telling me that I forgot to fill in a few things. But in the comments field you can see that code. I have checked for errors and I don't see anything. So I don't know whats going on. Visit my web site at
http://www.new-era-designs.com/contact2.html and fill out the application. You see that when you fill it out and actually fill in the comments box everything works correctly. But if you remove the current text in the box and leave it blank and continue on you see on the next page that the code is there. What is up with that? Can somebody help me?
**Thanks in advance**
Posted: Fri Dec 13, 2002 11:28 pm
by nathus
you're not closing your textarea tag. a textarea is a container tag, has an open and close tag. whatever text is between the 2 is what shows up in the textarea. also not sure why you're starting another form.
Posted: Fri Dec 13, 2002 11:32 pm
by GTCobra
I am new to PHP. I am really just experimenting. Are you able to see the code? The textarea tags are opened and closed correctly.
Posted: Fri Dec 13, 2002 11:35 pm
by GTCobra
I want the text inside the comment box before they write in it.
Posted: Fri Dec 13, 2002 11:41 pm
by nathus
when a php page is requested from the server, the server executes the script and displays the output, so you can't see the php source code by doing a view source.
however when I left the comments field blank, this is what I got.
Code: Select all
<form name=form method=post action=\contact_thanks.php><p class=bodymd>All of the fields are required in this field.
<p class=bodymd>Fill in the ones you missed, they are listed
below.<input type=hidden name=first1 value=Jon><input type=hidden name=last1 value=Smith><input type=hidden name=address1 value=2451>
<input type=hidden name=city1 value=Duluth><input type=hidden name=state1 value=Mn><input type=hidden name=zip1 value=55812>
<input type=hidden name=email
value=asdlk@asldkj.com><input type=hidden name=homephone1 value=555-555-5555>
<input type=hidden name=work value=555-555-5555><p class=bodymd>Comment<br><textarea cols='60' rows='6'
name=comment><form>
<input type=submit value=Submit><input type=reset value=Clear>
</form></h4>
the textarea isn't closed.
*note* just tried again, and it worked fine /shrug you fix it?
Posted: Fri Dec 13, 2002 11:45 pm
by GTCobra
Well I got it. It was by my comments fields in my php code.
Thanks to the person who pointed it out!

Posted: Fri Dec 13, 2002 11:49 pm
by GTCobra
Check this out. If you fill it out and leave the comments blank, it works. You get to the next page and fill in something into the comments box and hit submit, then it takes you to another page and asks for your home number again, now that I don't get.
****I found the problem****
Must be late in the night or something

Posted: Fri Dec 13, 2002 11:57 pm
by nathus
worked fine for me. I would however suggest that you put quotes around the form field names and values in the html code.
Posted: Fri Dec 13, 2002 11:59 pm
by GTCobra
Thanks for the suggestion. By the way, now that this is working, how can I get the code to accurately work? Meaning, when somebody puts in a phone number, I want number, not letter. Or in an email, it checks to make sure the '@' sign is there.
Posted: Sat Dec 14, 2002 12:19 am
by nathus
you could use a regular expression to match patterns in the input strings.
is a pretty decent article on writing regular expressions at
http://www.phpbuilder.com/columns/dario19990616.php3
for example, to match an email address thats in the form of
name@domain.com you would use something like
if (ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $email))
echo "is a valid email";
of course not all email addresses are formatted like that. is just an example.
Posted: Sat Dec 14, 2002 12:24 am
by GTCobra
Yeah, I'll take a look at that article because I want to learn how to do that. I want to learn validation in PHP.