Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts

    send data to database after that goto other page


    i have some data which is send to data base i want to go to other page after sending data how can i do this?????

    if im doing in action="example.php" its not working it goes to the page but data not sent.

    if im doing it with its self
    Code:
    action="<?php echo $_SERVER['PHP_SELF']; ?>"
    it sends the data and stays on that page???

    what should i do?

    send data to data base and goes to other page for further process.


    Code:
    	<form name="tstest" action="" method="POST">
       ** <CENTER>From : <select name="fromcombo"> 
    <option value="khairpur">Khairpur</option>
    <option value="sukkur">Sukkur</option>
    </select>*******
    
    To : <select name="tocombo">
    <option value="karachi">Karachi</option>
    <option value="hyderabad">Hyderabad</option>
    </select></CENTER><br /><br><br>
    
    <CENTER>Journey Date*:*<script type="text/javascript" language="javascript">
    (INPUT(NAME("DV")+READONLY())+INPUT(TYPE("button")+VALUE("Calender")+ONCLICK("popCal(this.form.DV)"))).FORM().write();
    </script></CENTER><br><br><br>
    
    
     <input type="hidden" name="action" value="add">
    
    <center><input type="submit" value="Submit Info" /></CENTER>
    
    </form>

    PHP CODE

    Code:
    <?php
    
    if (isset($_POST['action'])){
    
    mysql_connect("localhost", "root", "autodeskmaya");
    header("Location: http://localhost/site/checkstatus.html");
    
    mysql_select_db("online_bus_project");
    
    
    mysql_query("INSERT INTO trip (gender, country, date) VALUES ('$_POST[fromcombo]', '$_POST[tocombo]', '$_POST[DV]')"); 
    
    
    }
    
    ?>
    Last edited by m-hrt; 05-13-2009 at 06:38 PM.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    If you put your INSERT query in example.php, and then direct to example.php on the form action parameter, then I think you'll have what you want.

  • #3
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    can u show me a example how to do this?

  • #4
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    i understand now let me try it ill let u know if it works thanx

  • #5
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    no its not working any other solutions?

  • #6
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    same no data send it direct to example.php but it wont send the data to table.

  • #7
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Echo your $_POST array using print_r() at the top of example.php to see if you're even getting the form data over.

  • Users who have thanked Fumigator for this post:

    m-hrt (05-13-2009)

  • #8
    New Coder
    Join Date
    May 2009
    Posts
    40
    Thanks
    3
    Thanked 0 Times in 0 Posts
    its working with header thanx Fumigator rep added.

    thanx for the help


  •  

    Posting Permissions

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