1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with creating static website from a form using PHP

Discussion in 'PHP & Perl' started by pasenseoso, Oct 26, 2013.

  1. pasenseoso

    pasenseoso Power Member

    Joined:
    Aug 19, 2011
    Messages:
    754
    Likes Received:
    136
    Occupation:
    hachetman
    Location:
    - - P I L I P I N A S - -
    Home Page:
    Hi Guys..

    I need help to create a static page out from a reservation page for a real estate website project.

    I wanted to "save" a particular page after the user submits the form but isn't visible to them but they will be redirected somewhere. So the scenario is as follows :

    user is in the reservation page where he/she inputs details then clicks "submit" -> the form with its entries will be saved in a .txt file (invisible to user) -> user is redirected to a thank you page.

    The saved .txt file in a specific directory will then serve as a transaction receipt between the client and agent. The file can then be "downloaded" via the sales agent's and the sales manager email every time a transaction is made online.

    I wanted to have this type of scheme so property agents will not steal each others' clients because they are fighting over claiming the clients (and commissions) as of with our current system.


    Hope to get some great suggestions with you guys...
     
  2. jairathnem

    jairathnem Power Member

    Joined:
    Oct 27, 2010
    Messages:
    550
    Likes Received:
    316
    Occupation:
    Student
    Location:
    Incredible India!
    Home Page:
    This is possible with PHP. Not too complex.
    just curious, why do you want to save it in txt file and not in a DB.
    you can extract from DB and display it to the client.
     
  3. pasenseoso

    pasenseoso Power Member

    Joined:
    Aug 19, 2011
    Messages:
    754
    Likes Received:
    136
    Occupation:
    hachetman
    Location:
    - - P I L I P I N A S - -
    Home Page:
    Because I want it to serve as a receipt so sales agents can print it out and show it to the office for documentation. Because the company has a policy that a client signed under their name will expire in just thirty days. Plus the company manager has no idea about database things and he told me that it can easily be "gamed". So printing out the transaction receipt is the best choice.

    So how can I accomplish this?
     
  4. cz1349

    cz1349 Newbie

    Joined:
    Oct 31, 2013
    Messages:
    11
    Likes Received:
    2
    Depends where you are sending data, what are you sending and how (POST/GET), but I suppose that to form.php, sending client name only over GET method:

    Code:
    <?php
    
    //GET VALUE from <input type="text" name="client_name"/> SEND OVER GET METHOD
    $client_name = $_GET['client_name']
    
    //OPEN FILE NAMED saveToThis.txt
    $fileToSave = fopen('saveToThis.txt','w');
    
    //WRITE TO FILE LINE WITH CLIENT NAME
    fwrite($fileToSave, "Client name: " . $client_name); 
    
    //CLOSE FILE
    fclose($fileToSave);
    
    //AFTER SAVE YOU WILL REDIRECT TO THANK YOU PAGE
    header('Location: thank-you-page.html');
    
    ?>
    
    It is not full script, but should give you good starting point ... btw, I created it directly from head, so not tested ... but it should works ;)
     
    • Thanks Thanks x 1
  5. sirish

    sirish Newbie

    Joined:
    Jul 22, 2013
    Messages:
    2
    Likes Received:
    0
    PHP can solve your problems but developing a full fledged form will take more details..
    Also, using database is still better option.
     
  6. pasenseoso

    pasenseoso Power Member

    Joined:
    Aug 19, 2011
    Messages:
    754
    Likes Received:
    136
    Occupation:
    hachetman
    Location:
    - - P I L I P I N A S - -
    Home Page:
    Thanks guys...

    Yeah It should also be stored in the database and also a text file for receipt. It is done this way so that sales agents will have proof who closed the deal first for a common client. thanks guys... I'm working on it now.. :)