Jump to content

Query messages?


Recommended Posts

A really simple question, But because its so simple, I didn't know what to look for.I have a registration form that register new clients into mysql database,Now, If everything goes well, the users are being directed to the main page, registered with a cookie,But what happen if they have error(s), I want the user to be redirected back to the Register_form page again with all the relevant errors displayed,My question is, how do i query the error messages in a different page?Scheme : Register_Form->if(no errors)->Set new user cookie and head back to main page with the user logged in, else->Redirect back to the Register_Form page with all the relevant error messages.Thanks in advance

Edited by Illasera
Link to post
Share on other sites

I'm confused. You said you want the error message in a different page, yet later on you say you want them on the same page.At any rate, you just need to use a variable and add on error messages that way. Once your done, just echo out the variable wherever you want the error message to appear.

// initializes $err with a empty string.$err = "";// assign error messages to $errif ($a != 1) {$err .= "Variable A is not equal to one. <br />";}if ($b != 2) {$err .= "Variable B is not equal to two. <br />";}// display your error messagesecho $err;

Personally, I use an error function. It allows me to format the error message with red/green colors and proper spacing before they are assigned to the variable.

Link to post
Share on other sites
I'm confused. You said you want the error message in a different page, yet later on you say you want them on the same page.At any rate, you just need to use a variable and add on error messages that way. Once your done, just echo out the variable wherever you want the error message to appear.
// initializes $err with a empty string.$err = "";// assign error messages to $errif ($a != 1) {$err .= "Variable A is not equal to one. <br />";}if ($b != 2) {$err .= "Variable B is not equal to two. <br />";}// display your error messagesecho $err;

Personally, I use an error function. It allows me to format the error message with red/green colors and proper spacing before they are assigned to the variable.

My question is, how do i query the error messages in a different page?
Didn`t know it was hard to understand but ok, hmmmmMaybe this will be more clear3 pages = Homepage.html, Register_Form.php, RegisterClient.phpHomepage.html (Homepage), Register_Form.php (Where the user write down his data to process in RegisterClient once form is submitted.)RegisterClient.php(Where the server look for errors, if everything is ok, redirect to homepage.html, if not , redirect to Register_Form.php with errors supplied to refill the form again).User visit Homepage.html and want to register procedure : Homepage.html->Register_Form.php->RegisterClient.phpif(no errors)RegisterClient.php->Homepage.htmlelse(errors)RegisterClient.php->Register_Form.php (with errors from RegisterClient.php) Edited by Illasera
Link to post
Share on other sites

If you want your data to last more than 2 pages (back and forth included), you will need sessions or may use the GET method. However those methods aren't very effective for what you're trying to do. Have you tried to validate your data on the same page where the form is? Basically, if you put the code of RegisterClient.php inside of Register_Form.php you can resolve this issue.

Link to post
Share on other sites
If you want your data to last more than 2 pages (back and forth included), you will need sessions or may use the GET method. However those methods aren't very effective for what you're trying to do. Have you tried to validate your data on the same page where the form is? Basically, if you put the code of RegisterClient.php inside of Register_Form.php you can resolve this issue.
hmmmmm, I was thinking about sessions but seems a bit risky... GET method ... I don`t think they can handle the data very well like your said, To much info to transfer...Same page... I need to see if that can be done but thanks mate :)
Link to post
Share on other sites

It's fine to use the session, why do you think that's risky? Otherwise, it's common to have the code which processes a form on the same page that the form gets displayed, for this reason. There's some information about processing forms here:http://w3schools.invisionzone.com/index.php?showtopic=12509

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...