Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 08-07-2004, 08:05 PM   #1
Member (10 bit)
 
GSXdan's Avatar
 
Join Date: Jun 2002
Location: P-burg, Ohio, USA
Posts: 555
Send a message via AIM to GSXdan
combining php w/ html...

On a test-site im developing(mostly to learn php/mysql), I have a user registration area. Now if they fill out the form, but either forget to input a required element, or if the email or username is already in the database, it gives an error message. Only problem is the error messages show up at the very top of the site, about the banner etc. How do I get these to show in the same place taht the form is?

Check it out to see exactly what I mean: http://dcrcomps.net/gathering/register.html

Just dont put in an email address to see what i mean.

Next thing, and it goes along with the last thing, if someone does register successfully, how can I get that message displayed in the same spot as the form? Right now I just have it doing an echo "you are registered..blah blah blah" at the bottom of my register.php, so its just a blank white page with the statement on it.

I assume that somehow the html and php have to be combined somehow, but Im not sure exactly what to do.

attached is my register.html and register.php files.

Thanks
Attached Files
File Type: zip register.zip (4.5 KB, 14 views)
GSXdan is offline   Reply With Quote
Old 08-08-2004, 01:45 PM   #2
Member (8 bit)
 
neouser99's Avatar
 
Join Date: Jun 2004
Location: Kansas City, MO
Posts: 157
Send a message via AIM to neouser99
just put the echo code for the error output within the table.

i can't open .zip files from this computer, but i assume that you have all your php at the top, then the html after it.

you can put php anywhere in a .php file, as long as it is between tags...and also as many instances as you want... so still run your test vars at the top, then just output the array right about the table.

-neo
neouser99 is offline   Reply With Quote
Old 08-11-2004, 06:50 PM   #3
Member (9 bit)
 
Join Date: Oct 2003
Location: Minnesota, USA
Posts: 382
Send a message via AIM to MrAustin
One of the more popular ways to do this is to create a system of error codes, such as the following:

1. First Name not entered
2. Last Name not entered
3. Email not entered
4. Username not entered

Let's say they did not enter FirstName, LastName or UserName, then the error code would be "124", stored in the hidden form field named "code" and processed thus:

PHP Code:
if(substr_count($code"1") > 0) {
  echo 
"<span style=\"color: red\">First Name is Required</span>";
}

...
HTML HERE...

if(
substr_count($code"4") > 0) {
  echo 
"<span style=\"color: red\">User Name is Required</span>";
}

...AND 
SO ON... 
So on and so forth so that the PHP is executed wherever you want the text to appear. Note that this requires you to compile the error code (which would be best done by Javascript and put into a hidden form field) and re-send it back to the form for processing by these snippets. If you have questions, PM me or reply

Hope to help.

Last edited by MrAustin; 08-11-2004 at 06:53 PM.
MrAustin is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 06:51 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2