Hey guys,
well im new to the php scene, but want to put this form which will auto-generate a new page (example : www.abc.com/123 or something like that) and then send a thank you email with the link to the auto generated page to the recipient.

it will have fields of name/email/phone/address/country/drop down area/text area/image upload area.

this is like it, i want some help with this form development. will be very thankful for the help you will post.

thanks already!

Edited by samxa: spelling

5 Years
Discussion Span
Last Post by diafol

Could you provide more info? You want to send dynamic to an email address containing a link based on the data sent by a form?
Is so, give details of the form data and the type of output to email you require


Hi, thanks for your reply to the post.
Well my aim is to have a form an its data submitting to my specified email (like a regular form). On submit, i want the script to auto generate a page (ex. abc.com/123). An send a thank you mail to the form submitter with the (ex. abc.com/123) link. Thanks!


As opposed to creating a static file/page - you'd be better off storing that data in a database that can be retrieved by simple querystring parameter, e.g. abc.com?id=23478bhjwfe876234

This can be prettified using Apache mod rewrites to something like abc.com/23478bhjwfe876234/ using the .htaccess file.

If you provide the form data that you want to pass, perhaps we can advise you further. This seems to be a trivial wrt coding - so the solution should be straightforward. Just depends on what you want to pass from the form and what you want to display / send via email.


Appreciate your feedback to the query.

Well to refine the query, i'm providing the link of a post which is similar to what i want to achieve. (http://stackoverflow.com/questions/6261163/how-to-automatically-generate-a-page-after-user-fills-a-form-via-php)
- In this post, the person is asking for a php script where there are 2 fields which TITLE & COMMENT and auto creates a page with TITLE as the URL and the COMMENT in the auto created page.

Same way, i want it to auto create a page on submit have the name of the user submitting the form to be the URL (ex : abc.com/michael%page or somthing like that) and submits the form data via email to me. (i dont want the user submitted form to display the data in the auto created page)

Alongside, after submission and auto page creation, i want the script to submit an email to the user's email which will contain the auto created page URL (abc.com/michael%page)

I'm also providing the link of my form which is in question.
(http://formtest.0fees.net/form.html) - kindly view!

Thanks a ton!


I'm a little confused as to what is going to be on the 'auto-created' page if nothing to do with the form data!

creating a page is simple:

//include DB connection and selection

if(isset($_POST['element_2']) && !empty($_POST['element_2'])){
    $post = array_map('mysql_real_escape_string',$_POST);
    //check - validate individual array items - if all ok -

    //function to set suffix increment number in case of duplicate names (bit crass but it was a quickie!)     
    function loopFind($name){
        $r = mysql_query("SELECT name FROM users WHERE name LIKE '$name%'");

        while($d = mysql_fetch_assoc($r)){
            $dbnames[] = $d['name']; 
        if($x > 0)$name .= $x;
        return $name;

    //slugify to make url safe (from: http://snipplr.com/view/22741/)
    function slugify($name){
        // replace non letter or digits by -
        $name = preg_replace('~[^\\pL\d]+~u', '-', $name);
        // trim
        $name = trim($name, '-');
        // transliterate
        if (function_exists('iconv')){
            $name = iconv('utf-8', 'us-ascii//TRANSLIT', $name);
        // lowercase
        $name = strtolower($name);
        // remove unwanted characters
        $name = preg_replace('~[^-\w]+~', '', $name);
        if (empty($name)){
            return 'n-a';
        return $name;

    //set incrementer and slugify
    $name = loopFind(slugify($post['element_2']));

    $r = mysql_query("INSERT INTO users SET name = '$name', email='{$post['email']}'");
    //add all the other fields to the db table above or to multiple tables - depending on how you are storing your data 
    $link = "http://www.abc.com/$name/";

    $to  = $post['email'];

    // subject
    $subject = 'Your Post to SiteABC';

    // message
    $message = '
      <title>Your Post to SiteABC</title>
      <p>This is your link: <a href="' . $link . '">' . $link . '</a>

    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'To: '. $name .' <' . $post['email'] . '>' . "\r\n";
    $headers .= 'From: Site Name Admin <admin@abc.com>' . "\r\n";
    $headers .= 'Bcc: admin@abc.com' . "\r\n";

    mail($to, $subject, $message, $headers);


OK, this is totally hand coded (except for the copy/paste from the php.net manual and the slugify stuff) so it's not tested. It's a bit of a mongrel, but it should work if you change the .htaccess file to something like this:

RewriteEngine On
RewriteRule ^([^/]*)/$ /index.php?user=$1 [L]

This assumes that your pages will be served through index.php and with the parameter 'user'. So in order to display your user's data:

    //check for name in DB with select sql
    //if exists - show the data
    //if it doesn't exist show a generic 'no known user' data

Few ramblings, other ideas exist. Anybody with a better idea / solution.

Edited by diafol


diafol, thanks for the help till now sir!

the script looks perfect for the page creation and link submission to user email.

The auto created link, what in case one user submits the form again, could it take him to the page already existing??

Though small changes, i want the input data of the form to be EMAILED to my speicified email id, as seen here http://formtest.0fees.net/form.html the form has multiple fields including a upload photo field, i want all this emailed to me. Also, how do i add the script to process and send the form data to be submitted to my email??

The auto-created link also needs to be included in the user form data submitted to my email.

Also the auto-created page will be created/contain a template page which will be stored in the web.

it will be great if u could modify these.

Thanks a lot!!


it will be great if u could modify these.

I'm sure it would. But I'm not going to do that, sorry. I've given you a freebie, maybe somebody else with join in?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.