Ready to get started?Download WordPress


Contact Form 7
On submission, create XML (1 post)

  1. jainsy
    Posted 4 years ago #

    Hi all,

    I am sending the user to a page after submitting the Contact Form 7 as I would like to create an XML file with the form data. At the moment I just have a firstName field and a lastName field. My code is below (I used to use it with a standard PHP form). You can see I'm trying to get the values using php post. Is there anyway i could get the submitted values with contact form 7? If not, could i include this code elsewhere in the plugin perhaps?

    Really need this to work!!!

    $firstname = $_POST["firstName"];
    $lastname = $_POST["lastName"];
    $date = date("D M j H:i:s T Y");
    $valid = "true";
    $homedir = "";
    $weblead = "";
    $_SESSION["firstname"] = $firstname;
    $_SESSION["lastname"] = $lastname;
    if ( $firstname == "" || $lastname == "" )
    	$_SESSION["error"] = "Please make sure mandatory fields are filled out";
    	$valid = "false";
    elseif ( ! ereg("^[A-Za-z -]*$", $firstname) )
    	$_SESSION["error"] = "Please make sure the first name is valid";
    	$valid = "false";
    elseif ( ! ereg("^[A-Za-z -]*$", $lastname) )
    	$_SESSION["error"] = "Please make sure the last name is valid";
    	$valid = "false";
    if( $valid == "false" )
    	header("Location: demoWEBLEAD.php");
        //Create a file with the filename being related to time, conforming to previous files
        $filename = time(rand(10, 10));
        //populating and formatting data for the weblead
        $weblead = "{
       \"firstname\" = \"$firstname\";
       \"lastname\" = \"$lastname\";
        //opening the file for being writable and putting the weblead info into it
        $webleadfile = fopen($homedir . $filename, "w+b");
        fputs($webleadfile, "$weblead");
        //just for quick reference on the thank you page.
        $_SESSION["weblead"] = $weblead;
        $_SESSION["filename"] = $filename;
        //redirect to thank you page
        header("Location: thankyouWEBLEAD.php");

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic