12 Replies - 7751 Views - Last Post: 24 March 2009 - 12:42 AM Rate Topic: -----

#1 chrisp200  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 82
  • Joined: 18-November 08

Create new page on submit

Post icon  Posted 22 March 2009 - 10:15 PM

when a user submits the form the information will be sent to 1.php

What can I do to so when a second form is submitted the information will create an be sent to 2.php and a third submission would be 3.php and so on...



Thank you very much

  <html>
<head>
<title>Form to Flat File</title>
</head>
<body>
<?php

$user = $_GET["name"];
$message = $_GET["message"];
print("<b>Thank You!</b><br />Your information has been added! You can see it by <a href=1.php>Clicking Here</a>");
$out = fopen("1.php", "w");
if (!$out) {
print("Could not append to file");
exit;
}
fputs ($out,implode,("\n"));
fwrite($out,"<b>$user</b><br />$message<br /><br />");
fclose($out);
?>
</body>
</html> 



Is This A Good Question/Topic? 0
  • +

Replies To: Create new page on submit

#2 chrisp200  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 82
  • Joined: 18-November 08

Re: Create new page on submit

Posted 22 March 2009 - 11:24 PM

Can I just use an if statment somehow?

This post has been edited by chrisp200: 23 March 2009 - 12:48 AM

Was This Post Helpful? 0
  • +
  • -

#3 chrisp200  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 82
  • Joined: 18-November 08

Re: Create new page on submit

Posted 23 March 2009 - 01:21 AM

no ideas? or is just too late for everyone?
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5364
  • View blog
  • Posts: 27,325
  • Joined: 10-May 07

Re: Create new page on submit

Posted 23 March 2009 - 01:27 AM

Untested, but should get you in the right direction...
<html>
<head>
<title>Form to Flat File</title>
</head>
<body>
<?php
  if(isset($_GET['page'] $page=$_GET['page'] + 1;
  else $page=1;
  $user = $_GET["name"];
  $message = $_GET["message"];
  print("<b>Thank You!</b><br />Your information has been added! You can see it by <a href=".$page.".php>Clicking Here</a>");
  $out = fopen($page.".php", "w");
  if (!$out) {
	die("Could not append to file");
  }
  fputs ($out,implode,("\n"));
  fwrite($out,"<b>$user</b><br />$message<br /><br />");
  fclose($out);
?>
</body>
</html> 


Was This Post Helpful? 1
  • +
  • -

#5 chrisp200  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 82
  • Joined: 18-November 08

Re: Create new page on submit

Posted 23 March 2009 - 01:45 AM

very nice, thank you!

still doesnt create a new php file it just overwrites.
ill continue to try to figure it out.
if you have any more suggestion, I'm all ears! Thanks again

<html>
<head>
<title>Form to Flat File</title>
</head>
<body>
<?php
  if(isset($_GET['page'])) $page=$_GET['page'] + 1;
  else $page=1;
  $user = $_GET["name"];
  $message = $_GET["message"];
  print("<b>Thank You!</b><br />Your information has been added! You can see it by <a href=".$page.".php>Clicking Here</a>");
  $out = fopen($page.".php", "w");
  if (!$out) {
	die("Could not append to file");
  }
  
  fwrite($out,"<b>$user</b><br />$message<br /><br />");
  fclose($out);
?>
</body>
</html> 


Was This Post Helpful? 0
  • +
  • -

#6 chrisp200  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 82
  • Joined: 18-November 08

Re: Create new page on submit

Posted 23 March 2009 - 07:17 PM

I thought I figure it out but it still doesnt create a new file, it just replaces the exsisting on on click
Was This Post Helpful? 0
  • +
  • -

#7 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5364
  • View blog
  • Posts: 27,325
  • Joined: 10-May 07

Re: Create new page on submit

Posted 23 March 2009 - 10:14 PM

It's not common practice to write php files on the fly. Usually they are coded & then used for processing. Like write once read many.

Maybe give a little more detail as to the scope of your project, & there might be a better, more efficient way to achieve what you are after.
Was This Post Helpful? 0
  • +
  • -

#8 chrisp200  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 82
  • Joined: 18-November 08

Re: Create new page on submit

Posted 23 March 2009 - 10:59 PM

View Postno2pencil, on 23 Mar, 2009 - 09:14 PM, said:

It's not common practice to write php files on the fly. Usually they are coded & then used for processing. Like write once read many.

Maybe give a little more detail as to the scope of your project, & there might be a better, more efficient way to achieve what you are after.



What I am trying to do is create a place where people could post job openings. So when they submit the form the name of the company, and the position available would display on a page. With the link to the job description being included in the position available. I'm trying to do it the simplest way possible at this point for practice.
Was This Post Helpful? 0
  • +
  • -

#9 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: Create new page on submit

Posted 24 March 2009 - 12:16 AM

Simple Just from use Session Variables
$_SESSION['AnyName']=$_POST['AnyName'];


so u can use it every where in every page by using
echo $_SESSION['AnyName'];

Was This Post Helpful? 1
  • +
  • -

#10 chrisp200  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 82
  • Joined: 18-November 08

Re: Create new page on submit

Posted 24 March 2009 - 12:18 AM

a database would be needed then right?
Was This Post Helpful? 0
  • +
  • -

#11 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5364
  • View blog
  • Posts: 27,325
  • Joined: 10-May 07

Re: Create new page on submit

Posted 24 March 2009 - 12:18 AM

Not for sessions.
Was This Post Helpful? 0
  • +
  • -

#12 chrisp200  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 82
  • Joined: 18-November 08

Re: Create new page on submit

Posted 24 March 2009 - 12:20 AM

I dont really know much about sessions but wouldn't the person who posted the information be the only one who could see the information? And wont the post just be destoryed after a certain amount of time?

This post has been edited by chrisp200: 24 March 2009 - 12:32 AM

Was This Post Helpful? 0
  • +
  • -

#13 musya  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 11
  • View blog
  • Posts: 1,012
  • Joined: 25-April 07

Re: Create new page on submit

Posted 24 March 2009 - 12:42 AM

This is incorrect, you need to either store it in a db (not that hard plenty of tutorials out their on it and if you get stuck just post back here, we're more than glad to help) or just store it in a .dat file of some sort instead of php in a sence a db only much simpler. But your current practice is incorrect.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1