SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2003
    Location
    rotterdam
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    redirect my formscript

    I have made a simple form to add data in my database.
    The problem is that every time I press the submit button and want to add new data, I have to type the url again.
    I want to be able to add data continously every time after pressing Submit.

    <body>
    <?php
    include("connectzprovincie.php");

    if(!empty($prov)) {
    $prov= addslashes($prov);

    $sql= "INSERT INTO zprovincie SET provincie='$prov'";
    $query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());

    echo "Databse Updated.";
    } else {
    ?>

    <b>Add Provincie</b>
    <form name="zprovincie" method="post" action="<?php echo $PHP_SELF; ?>">
    Provincie : <input type="text" name="prov">
    <br>
    <input type="submit" name="Submit" value="Submit">
    </form>

    <?php
    header("Location: formprov.php");
    }
    ?>
    </body>


    formprov is the name of this file

  2. #2
    SitePoint Evangelist
    Join Date
    Jul 2001
    Location
    Michigan, USA
    Posts
    414
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Go ahead and try this:

    PHP Code:
    <body> 
    <?php 
    include("connectzprovincie.php" ); 
    if(!empty(
    $prov)) { 
    $provaddslashes($prov); 
    $sql"INSERT INTO zprovincie SET provincie='$prov'"
    $query mysql_query($sql) or die("Cannot query the database.<br>" mysql_error()); 
    echo 
    "Databse Updated.<BR><BR>"
    }
    ?> 
    <b>Add Provincie</b> 
    <form name="zprovincie" method="post" action="<?php echo $PHP_SELF?>"> 
    Provincie : <input type="text" name="prov"> 
    <br> 
    <input type="submit" name="Submit" value="Submit"> 
    </form> 
    </body>

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2003
    Location
    rotterdam
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx it works.
    But....is there a way that the sentence "database updated" disappears after say 3 seconds?

  4. #4
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup, just add a meta-redirect clause to the header:
    HTML Code:
     <meta http-equiv="REFRESH" content="3; URL=http://www.myotherpage.com">
    My name is Steve, and I'm a super-villian.


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
  •