Jump to content

Email form PHP Syntax error


Recommended Posts

Can anyone help, im setting up an email form and it is returning this error.
 
**Parse error: syntax error, unexpected 'isInjected' (T_STRING), expecting '(' in /storage/ssd4/339/5596339/public_html/send_mail.php on line 21**
 
**Html code:**
 
    <form action="send_mail.php" method="post">
    <p><br>
    <input name="Name" type="text" style="width: 325px; height: 40px" placeholder="Your Name *" required><p>
    <input name="Email" type="text" style="width: 325px; height: 40px" placeholder="Email Address *" required><p>
    <input name="Telephone" type="text" style="width: 325px; height: 40px" placeholder="Telephone Number *" required><p>
    <select name="Type" style="width: 325px; height: 40px" required>
    <option value="" disabled selected>Type of Move *
    </option>
    <option value="Home Move Only">Home Move Only</option>
    <option value="Business Move Only">Business Move Only</option>
    <option value="Home Move and Storage">Home Move and Storage</option>
    <option value="Business Move and Storage">Business Move and Storage</option>
    <option value="General Move">General Move</option>
    </select><p>
    <input name="From" type="text" style="width: 325px; height: 40px" placeholder="Moving From (Postcode) *" required><p>
    <input name="To" type="text" style="width: 325px; height: 40px" placeholder="Moving To (Postcode) *" required><p>
    <button name="Abutton1" style="width: 325px; height: 40px;" class="btn1" type="submit" value="Submit">Submit
    </button>
    <p align="left">
    <input name="Checkbox1" type="checkbox" required><span class="style7">I  accepted.</span></form>

**PHP Code**

    <?php
    $webmaster_email = "email@hotmail.co.uk";
    $feedback_page = "feedback_form.html";
    $error_page = "error_message.html";
    $thankyou_page = "thank_you.html";
    $Email = $_REQUEST['email'] ;
    $Telephone = $_REQUEST['Telephone'] ;
    $Name = $_REQUEST['Name'] ;
    $Type = $_REQUEST['Type'] ;
    $From = $_REQUEST['From'] ;
    $To = $_REQUEST['To'] ;
    $Checkbox1 = $_REQUEST['Checkbox1'] ;
    $msg = 
    "Name: " . $Name . "\r\n" . 
    "Email: " . $Email . "\r\n" . 
    "Telephone: " . $Telephone . "\r\n" . 
    "Type: " . $Type . "\r\n" .
    "From: " . $From . "\r\n" .
    "To: " . $To . "\r\n" .
    "Checkbox1: " . $Checkbox1 . "\r\n" .	
    function isInjected($str) {
	$injections = array('(\n+)',
	'(\r+)',
	'(\t+)',
	'(%0A+)',
	'(%0D+)',
	'(%08+)',
	'(%09+)'
	);
	$inject = join('|', $injections);
	$inject = "/$inject/i";
	if(preg_match($inject,$str)) {
		return true;
	}
	else {
		return false;
	}
    }
    if (!isset($_REQUEST['Email'])) {
    header( "Location: $feedback_page" );
    }
    elseif (empty($Name) || empty($Email)) {
    header( "Location: $error_page" );
    }
    elseif (empty($Name) || empty($Email) || empty($Telephone) || empty($Type) || empty($From) || empty($To)) {
    header( "Location: $error_page" );
    }
    else {
    mail( "$webmaster_email", "Feedback Form Results", $msg );
    header( "Location: $thankyou_page" );
    }
    ?>

Please help this is driving me mad.

 

Cheers

 

Richard

Edited by richyunspoken
Link to comment
Share on other sites

How would i go about fixing this issue?

 

As Barand mentioned, the following statement needs to be closed before you define the isInjected() function:

"Checkbox1: " . $Checkbox1 . "\r\n" .

You just need to replace the concatenation character with a semi-colon.

"Checkbox1: " . $Checkbox1 . "\r\n";
Link to comment
Share on other sites

And stop using the global REQUEST array - use the one that matters in each case whether it be $_POST or $_GET

 

And learn to place your functions outside the flow of your logic. Why interrupt your code with some extraneous block that is going to be used all over the place? Place functions at the end of your mainstream php code.

 

And add a 'from' address to your (missing) headers argument of the mail call. It is required and is not usually included in the .ini file so you should be sure to add it here. Read the manual.

 

Are confused now? :)

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.