开发者

PHP dynamically generate pages on form sumbit via post

开发者 https://www.devze.com 2023-02-18 23:02 出处:网络
I have a general question about php and mysql. So currently, I have a form in a html file that on sumbit gets posted to a code.php with some input processing in code.php.

I have a general question about php and mysql.

So currently, I have a form in a html file that on sumbit gets posted to a code.php with some input processing in code.php.

How would I go about generating different pages on submit with mysql and showing them the result from code.php?

So for instance, I have my domain example.com and on submit, it would generate a page example.com/1.php, and after, if I were to refresh the page and hit submit again, it would generate example.com/2.php?

I know my question is very general, just looking for a tutorial, or example开发者_JS百科 to code to follow!


I actually think what you are asking for is something like a step-by-step add process?

So what I write in page 1, page 2 and page 3 firstly wants to be added on page 4?

If that is the case you should read about serialize()-function in PHP.

E.g. on post you could make this: if( isset($_POST['step1']) ) { $_SESSION['step1_ok'] = 1; }

And then use the session for checking if the user comes from the last step. :)


I don't get your point, but to create a file you use fopen.


Not sure the point of this, are you trying to have a form that contains multiple pages?

You could just do that in 1 php page with something like:

<?php

  if(isset($_POST['step'])) {
    $step = $_POST['step']; 
  }
  else {
    $step = 1;
  }

  if($step == 3) {
    //show s3rd page
  }
  else if($step == 3) {
    //show 2nd page
  }
  else {
    //show 1st page
  }
?>

If you want the 1.php, 2.php, 3.php,.....

Then you should do something with mod_rewrite to make all those requests to to 'code.php' and then you would do something like above to figure out which of the virtual pages they tried accessing

Generating php code and then saving it as a php file which is then executed opens you up to a lot of security issues.


If your goal is to create the URL as you described for cosmetic reasons, perhaps you should look into mod_rewrite, or something similar.

http://articles.sitepoint.com/article/guide-url-rewriting

0

精彩评论

暂无评论...
验证码 换一张
取 消