Jump to content

Need Help (please) w redirect after form submission.


Rossp2000

Recommended Posts

Thank you in advance if you can help. Godaddy is leaving me hanging on this. I switched my deluxe hosting from Win to Lin to learn wordpress. In doing this, my active subdomain sites no longer have their form mail working. I switched from an gdform.asp to their gdform.php and have the forms working (I get the emails) however it defaults back to the root index page after form is submitted. I need them all to go to at least 1 page in one of my subdomain sites. Godaddy is completely unwilling to help with a seemingly easy request & I know nada about php programming.  >:(  In the meantime, I have 3 small business sites that are kind of dead in the water. Would someone here be able and willing to lend me a hand with this? It would REALLY be appreciated. Their provided form is gdform.php: (it reads like Latin to me)  :'(  Can I modify this file or do I need a new php script?

 

 

<?php

    $request_method = $_SERVER["REQUEST_METHOD"];

    if($request_method == "GET"){

      $query_vars = $_GET;

    } elseif ($request_method == "POST"){

      $query_vars = $_POST;

    }

    reset($query_vars);

    $t = date("U");

 

    $file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t;

    $fp = fopen($file,"w");

    while (list ($key, $val) = each ($query_vars)) {

    fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");

    fputs($fp,"$val\n");

    fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");

    if ($key == "redirect") { $landing_page = $val;}

    }

    fclose($fp);

    if ($landing_page != ""){

header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");

    } else {

header("Location: http://".$_SERVER["HTTP_HOST"]."/");

    }

 

 

?>

 

18775_.php

Link to comment
Share on other sites

I am no expert in this area, so I apologize if this doesn't work.  I assume the idea is to get the name of the subdomain and rebuild the path.  This is what I came up with.

<?php
    $request_method = $_SERVER["REQUEST_METHOD"];
    if($request_method == "GET"){
      $query_vars = $_GET;
    } elseif ($request_method == "POST"){
      $query_vars = $_POST;
    }
    reset($query_vars);
    $t = date("U");

    $file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t;
    $fp = fopen($file,"w");
    while (list ($key, $val) = each ($query_vars)) {
     fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
     fputs($fp,"$val\n");
     fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
     if ($key == "redirect") { $landing_page = $val;}
    }
    fclose($fp);
//find subdomain and rebuild path
$subdomain = strpos($_SERVER['HTTP_HOST'], ".");
$subdomain = substr($_SERVER['HTTP_HOST'], 0, $subdomain);
$path = "$subdomain/{$_SERVER['HTTP_HOST']}";

    if ($landing_page != ""){
   header("Location: http://$path/$landing_page");
   exit;
    } else {
   header("Location: http://$path/");
   exit;
    }
?>

EDIT:  My sample didn't work when I just tested it.  Sorry about that.  $_SERVER['HTTP_HOST'] is showing the subdomain path already so I'm not sure what the issue is with your code.  I would probably use relative paths anyway.

 

Link to comment
Share on other sites

In your opinion, is there any chance of this fixing my problem? :shrug:

 

There is a post titled here:

Simple php form question - How to redirect to page after submit?

? on: June 06, 2011, 02:58:03 pm ?

 

The code looks like:

<?

$subject="from ".$_GET['name'];

$headers= "From: ".$_GET['email'];

$headers.=$_GET['phone']. "\n";

$headers.='Content-type: text/html; charset=iso-8859-1';

mail("myname@company.com", $subject,  "

 

  " ."Name: " .$_GET['name']."

 

  " ."Phone: " .$_GET['phone']."

 

  " ."Email: " .$_GET['email']."

 

  " ."Message: " .$_GET['message']."

 

</body>

</html>" , $headers);

 

header("location: http://www.company.com/index.html");

 

?>

 

Could I used this solution in place of my existing gdform.php? Any help would REALLY be appreciated. GoDaddy is zero help to me and my sites are down (at least the forms are)

 

Thanks.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.