SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2003
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    2 form actions: one submit button

    Hi,

    How do I get these two parts to work at the same time with one click of the submit button?

    I need the cookie set if the form has been processed, but I'm not sure how to get both the cookie set *and* have the form processed on the other server.

    PHP Code:
    if (!empty($_POST['pst']))
    {
     if (empty(
    $_POST['email']) || !eregi('^[a-z0-9.]+@[a-z0-9.]+\.[a-z0-9]{2,3}$',$_POST['email']))
        {
            
    header('location:error.html');
            exit;
        }
        else
        {
            
    setcookie('luser',base64_encode('mlb.php'));
            
    header('location:mlb.php');
        

            exit;
        }

    and here's the form which is processed by a script on another server...

    PHP Code:
     <form action="http://somedomain.com/userpages/formprocess.php" method="post">
     <
    input type="hidden" name="username" value="yourusername">
     <
    input type="hidden" name="toemail" value="you@yourdomain.com">
     <
    input type="hidden" name="redirect" value="http://yourdomain.com/thankyou.html">
     <
    input type="hidden" name="categoryid[]" value="4">
     <
    input type="hidden" name="categoryid[]" value="5">
     <
    input type="hidden" name="categoryid[]" value="6">
     <
    input type="hidden" name="campaignid" value="22">

     <
    b>Please sign our guestbook:</b><br>
     <
    hr color=navy width="200">

     
    Name: <input type="text" name="FirstName" maxlength="20"><br>
     
    Email: <input type="text" name="Email" maxlength="50"><br>

     <
    br>
     <
    b>How can we help you?</b>
     <
    hr color=navy width=200>

     <
    input type="checkbox" name="helpwith[]" value="Baseball"Baseball<br>
     <
    input type="checkbox" name="helpwith[]" value="Football"Football<br>

     <
    br>

     <
    center><input type="submit" value="Submit"></center>

     </
    form
    any help greatly appreciated.

    thanks.

    takayuki

  2. #2
    <? james('rules'); ?>
    Join Date
    Jun 2004
    Location
    Wales, UK
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use include .
    PHP Code:
    if (!empty($_POST['pst'])) 

    if (empty(
    $_POST['email']) || !eregi('^[a-z0-9.]+@[a-z0-9.]+\.[a-z0-9]{2,3}$',$_POST['email'])) 
        { 
            
    header('location:error.html'); 
            exit; 
        } 
        else 
        { 
            
    setcookie('luser',base64_encode('mlb.php')); 
            
    header('location:mlb.php'); 
         

            exit; 
        } 

    include(
    "form_to_process.html"); 
    If knowledge is power - Why isn't our army librarians?!
    Statistics show that 63% of all statistics are fake.
    When i was little i broke my neck, and i havent looked back since .
    I completed the internet in 1 week. The end boss was pretty easy though .

  3. #3
    <? james('rules'); ?>
    Join Date
    Jun 2004
    Location
    Wales, UK
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK i think i mis understood you or something. If this for is on the other server. You'll need to use mysql_close() to close a DB connection. If you havent opened one, just do a mysql connect where appropriate and then execute the form code using include r just display it as it is.
    If knowledge is power - Why isn't our army librarians?!
    Statistics show that 63% of all statistics are fake.
    When i was little i broke my neck, and i havent looked back since .
    I completed the internet in 1 week. The end boss was pretty easy though .

  4. #4
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using Javascript you can make it onsubmit load a second page in a hidden iframe and then submit the normal page.

  5. #5
    SitePoint Zealot
    Join Date
    Jan 2003
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks 1337 and someonewhois. now i've got a few ideas to work with.

    1337: i can't do a mysql connect on the other server... do i need to do that?

    anybody else want to weigh in here? i'm still scratching my head.


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
  •