Jump to content

Feedback form problem


gnawz

Recommended Posts

I have a feedback form code which does email but does not display the correct content.

 

In place of the email address, it displays "+1"

 

And the body message is "1"

 

It works well when I test it on localhost.

 

As in

 

FROM: +1

 

MESSAGE:+1

 

What is missing in my code, some body help

 

My code

 

<?php
require_once 'functions.php';
require_once'template.php';

Head('Make an Order/enquiry');
?>

<div id="pgcontent">
<h3><em>Place your Order/Enquiry</em></h3>
<?php

// Change to your own email address

$your_email = "sunny@lavis-casual.com";

// This is what is displayed in the email subject line

$subject = "LAVIS-CASUAL email order/enquiry";

// This is displayed if all the fields are not filled in

$empty_fields_message = "<p>Please go back and complete all the fields in the form.</p>";

// This is displayed when the email has been sent
$thankyou_message = "<p>Thankyou. Your message has been sent. We will be contacting you shortly.</p>";

$name = "";

$email = "";

$message = "";

//Email variables
$name = stripslashes(isset($_POST['txtName']));

$email = stripslashes(isset($_POST['txtEmail']));

$message = stripslashes(isset($_POST['txtMessage']));


if (!isset($_POST['txtName'])) {
?>
<form name="frmOrder" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
    <p>
      <label>Full Name:</label>
      <br>
    <input type="text" title="Enter your name" name="txtName" size="50"></p>
    <p>
      <label>Email address:</label>
      <br>
      <input name="txtEmail" type="text" title="Enter your email address" value="" size="50">
    </p>
    <p><label>Your message:</label><br>
    <textarea name="txtMessage" cols="50" rows="5" title="Enter your message"></textarea>
    </p>
    <p><label title="Send your message">
    <input type="submit" value="Send" onClick="return checkOrder();"></label>
    <input name="Reset" type="reset" value="Clear form">
    </p>
</form>

<?php

}

else {

    // Stop the form being used from an external URL

    // Get the referring URL

    $referer = $_SERVER['HTTP_REFERER'];

    // Get the URL of this page

    $this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];

    // If the referring URL and the URL of this page don't match then

    // display a message and don't send the email.

    if ($referer != $this_url) {

        echo "You do not have permission to access this form from another URL.";

        exit;

    }

    // The URLs matched so send the email

    mail($your_email, $subject, $message, "From: $name <$email>");

    // Display the thankyou message

    echo $thankyou_message;

}
?>
<script>
function checkOrder()
{
with (window.document.frmOrder) 
{
	if (txtName.value.length < 3)
		{
		alert('Enter Your full name!');
		txtName.focus();
		return false;
		} 

	else if (txtEmail.value.length < 1 || txtEmail.value.indexOf("@", 0) == -1)
	{	        
	alert ("Please enter a valid email address!");
	txtEmail.focus();
	return false; 
	}   

	else if (txtMessage.value == "") 
	{
		alert('Enter your order/enquiry details!');
		txtMessage.focus();
		return false;
	} 

	else 
	{
		return true;
	}
}
}
</script>
</div>

<?php
Footer();
?>

 

Link to comment
Share on other sites

I saw one error that may be the cause of your issue. the following code

$name = stripslashes(isset($_POST['txtName']));

$email = stripslashes(isset($_POST['txtEmail']));

$message = stripslashes(isset($_POST['txtMessage']));

 

sets the variables to boolean values (or rather, to values returned from the isset() function. Since (i'm assuming) the post variables are already set, the isset function will return +1. Conversely, if they aren't set, it will return -1. you can fix that by the following:

 

if (isset($_POST['txtName'])){
$name = stripslashes($_POST['txtName']);
}
//etc for the other values

 

try that. Hope that helps!

 

Link to comment
Share on other sites

Because you are using the isset() function which will return 1 when true. I don't know where you got this code from. It is effectively stripping slashes from either a 1 or 0. I'm not sure why you are even using the stripslashes() function. isset() is not the best function to use when testing that a variable contains a value.

$name = stripslashes(isset($_POST['txtName']));

 

Corrected

if(strlen(trim($_POST['txtName']))) {
$name = $_POST['txtName'];
}

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.