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
https://forums.phpfreaks.com/topic/67672-no-php-code-but-php-logic/
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.

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

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.