SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to return to previous URL after submitting php form (website is local to computer

    Hey guys!

    So I wanted to make some sort of program from my friends bachelorette party to electronically submit rsvps and such, but I only know how to make websites, not how to program, so I'm making a website and burning it to disk.

    Anyway, I have "feedback.php" on my server and the form is submitting fine from locally on my machine, but I can't figure out how to redirect back to the previous page. This is the code I have so far:

    Code:
    		<?
    session_start();
    
    $_SESSION['ref'] = $_SERVER['SCRIPT_NAME'];
    ?>
    		<form action="http://grindesigns.com/feedback.php" id="form1" method="post">
                <fieldset>
                    <label>Your Name:<input name ="name" type="text"></label>
                    <label>Your E-mail:<input name="email" type="text"></label>
    				Will you be attending? <input type="radio" name="rsvp" value="yes">Yes<input type="radio" name="rsvp" value="no">No
                    <div class="btns"><a href="javascript:document.getElementById('form1').reset()" class="more">Clear</a><a href="javascript:document.getElementById('form1').submit()" class="more">Send</a></div>
                </fieldset>
    		</form>
    And here is my php file code:

    Code:
    <?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $rsvp = $_POST['rsvp'];
    
    $msg = "Name: $name\n";
    $msg .= "Email: $email\n";
    $msg .= "rsvp: $rsvp\n";
    $recipient = "amaress@gmail.com";
    $subject = "RSVP for Lauren!";
    $mailheaders = "From:$email\n";
    $mailheaders .= "Reply-To:$email";
    mail($recipient, $subject, $msg, $mailheaders);
    echo "RSVP Received!"; 
    ?>
    
    <html>
    <head>
    <script language="JavaScript">
    var time = null
    function move() {
    
    window.location = "<?php echo $ref ?>";
    
    }
    //-->
    </script>
    </head>
    <body onload="timer=setTimeout('move()',1000)">
    <h2>Redirecting back to main</h2>
    
    </body>
    </html>
    Currently, it just automatically refreshes the php page over and over again.

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    66 Post(s)
    Tagged
    2 Thread(s)
    How are you going to run this app? PHP and apache have to be installed on the machine its being put in.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •