Hey there guys!
I was just wondering how would i go about making automated image portal that when you fill out a form and upload your picture to the database, it creates a new page from a template and includes that picture within it?
I know the basics of php and mysql but don't know how to automatically make a new .html or .php from a template and include that uploaded picture on submit?
Thanks HEAPS in advance!
Ricky
How to create new pages automatically from a form with PHP ?
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: How to create new pages automatically from a form with PHP ?
Hello, Toxinhead.
here's what you want:
Template page(template.html)
PHP for dynamicly made page:
here's what you want:
Template page(template.html)
Code: Select all
<html>
<head>
<title>Dynamicly made page</title>
</head>
<body>
<div>
the picture is below!<br />
<!_!_!_!_PIC GOES HERE_!_!_!_!>
</div>
</body>
</html>Code: Select all
<?php
//upload pic and save it to a location
$pic = 'pic location';
$template = file_get_contents('template.html');//get template
$template = explode('<!_!_!_!_PIC GOES HERE_!_!_!_!>', $template);//breakup template at specified point
$template = $template[0] .'<img src="'. $pic .'" />'. $template[1];// add <img> tag to template, and implode all in one
fwrite(fopen('new_page.html', 'w'), $template) or die('Couldn\'t make page');//write content to new page, in "w" mode, to make a new one
echo 'Page made successfully';
?>