Jump to content

no php code, but php logic!!


TheFilmGod

Recommended Posts

Hey,

 

I don't have a question about php coding, just about php logic.

 

I want to create a registration page that self processes itself.

 

if ( submit ... blah bla blah)

 

else (show form)

 

 

Problem is I want to have error reporting!! How can I use this structure to check for any errors and if there is an error, it shows the form and the error? ???

 

Maybe something like die(), but I"m not sure. Any ideas?

Link to comment
Share on other sites

You could simply have your form processing section create a multidimension array of errors. Then you would use something like...

 

<?php

  if (isset($_POST['submit'])) {
    // process.
  } elseif (!isset($_POST['submit'] || isset($errors) {
    echo "<form>";
    echo "<input type='text' name='uname'>" . isset($errors['uname']) ? " You didn't fill in the username" : "";
    // etc etc
  }

?>

 

Hope this helps.

Link to comment
Share on other sites

if is the first thing to be tried to get excuted! if you have lets say 10 if statement and they all equal true then you get the equivalence of all 10 statements! if you have 1 if statement and 10 ifelse then it sees if the first if statement is true and if not then it goes through the list until it finds on that is ture, then excecutes it and dies the script not allowing the others to excecute even if tru. If you have an if, 100 ifelse and an else, it sees if the if is true if not it looks at all the elseif's and if none of those are true then it excicutes the else

Link to comment
Share on other sites

if (!isset($_POST[submit])) {
    $show_form = "yes";
} elseif (isset($_POST[submit])) {
    //do process
} //end if


if ($show_form == "yes") {
   $display = "<form ...
} //end if

 

 

Use $_SERVER[php_SELF] for the form action

 

then print the display code later in html

 

<html>

<head>

...

</head>

<body>

<?php print "$display"; ?>

 

</body>

</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.