Jump to content

[SOLVED] no data being transferred with my php script


stupid girl!

Recommended Posts

I saw the code  ;D, it is working. The mail is sent to "[email protected]". Is this mail real ? Do you have access to it ?

 

Try keeping it in a variable like you did in your code

<?php $to = '[email protected]'; 
// and in mail keep like this 
mail($to, $subject, $message, $from);

 

Here is one example from PHP manual

 

<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?> 

n~ link=topic=166708.msg734390#msg734390 date=1194451666]

I saw the code  ;D, it is working. The mail is sent to "[email protected]". Is this mail real ? Do you have access to it ?

 

Try keeping it in a variable like you did in your code

<?php $to = '[email protected]'; 
// and in mail keep like this 
mail($to, $subject, $message, $from);

 

Here is one example from PHP manual

 

<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?> 

 

tried that and hasnt worked again. no [email protected] is not the real address it comes though to my email at the moment

yeah

 

this is the email output that comes through to my inbox

 

Wednesday, November 7, 2007, 4:18 pm [EST]

 

From:  ()

 

Title: 

 

Name: 

 

Address1: 

 

Address2: 

 

Postcode: 

 

Telephone: 

 

Mobile: 

 

Email: 

 

Type of Property: 

 

Is your property on the market?: 

 

If so Which Agent?: 

 

How Much: 

 

Do you wish to stay as a tenant?:

 

From:  ()

 

Additional Info : IP = 

 

Browser Info: 

 

Referral : 

 

 

<?php
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($firstname) || empty($visitormail) || empty($mobile) || empty($cost )) {
echo "<h2></h2>\n";
}
$to = '[email protected]';
$todayis = date("l, F j, Y, g:i a") ;

$attn = $firstname ; 
$subject = "Valuation form from Homes Bought Today" ; 

$notes = stripcslashes($notes); 

$message = " $todayis [EST] \n
From: $firstname ($visitormail) \n
Title: $title \n
Name: $firstname \n
Address1: $address1 \n
Address2: $address2 \n
Postcode: $postcode \n
Telephone: $telephone \n
Mobile: $mobile \n
Email: $visitormail \n
Type of Property: $proptype \n
Is your property on the market?: $propmarket \n
If so Which Agent?: $agent \n
How Much: $cost \n
Do you wish to stay as a tenant?: $tenant\n
From: $firstname ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";
mail($to, $subject, $message, $from);

?>

Why not just try something simple in your sendemail.php script like :

 

<?php

$to = "[email protected]";
$subject = " my subject ";
$message = " blah blah blah $_POST['firstname'] ";

if(mail($to, $subject, $message)){
  echo "mail sent";
}

?>

 

At least this way you're going to see the firstname :)

Your code is not good I meant , when I submit the form here http://www.homesboughttoday.co.uk/sendemail.php without filling out any fields then this message comes

Thank you for submitting your valuation form

One of our agents will be in contact shortly

 

I meant it is not really good thing in a live site.

 

And you have PHP codes in your HTML files too, in request.html

 

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
                                            <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
                                            <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />

aschk your code returned this error

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/homes/public_html/sendemail.php on line 130

 

 

neo the php in the form was suggested by the original writer in another forum a long time ago.

 

im appreciating all the help but i have no idea why this will not just work?

That's interesting, considering my code is only about 10 lines long...

Put all that code ONLY into your sendemail.php file. Backup your old one and run mine in it's place.

 

Also you might like to put this at the bottom before the last ?>

print_r($_POST);

 

This will tell you what you have in your post from the previous form.

i just tired the exact same forms on another server and got this email back for the fields i filled in

 

 

Wednesday, November 7, 2007, 4:45 pm [EST]

 

From: test ([email protected])

 

Title: test

 

Name: test ;

Address1: test

 

Address2: test

 

Postcode: 

 

Telephone: 

 

Mobile: 

 

Email: [email protected]

 

Type of Property: Please Select

 

Is your property on the market?: Please Select

 

If so Which Agent?: 

 

How Much: 

 

Do you wish to stay as a tenant?: Please Select

 

From: test ([email protected])

 

Additional Info : IP = <?php echo $ipi ?>

 

Browser Info: <?php echo $httpagenti ?>

 

Referral : <?php echo $httprefi ?>

 

 

Yeah I thought so , having just checked your script and your phpinfo information.

You're using the much antiquated global variables, so when you submit a form you're expecting $firstname to be a variable. This is OLD syntax and I hurriedly recommend you move onto the newer format which has been present since 4.1.0 .

 

Use $_POST['firstname'] instead of $firstname.

Currently your php information shows that you have register_globals set to "Off" and too rightly too. It's a security nightmare. Start using the correct $_POST & $_GET parameters now please.

 

No wonder it didn't work, we all thought you were converting your local variables like $firstname = $_POST['firstname'] , lol

First of all I suggest you to rename your request.html file to request.php file (where the form is) , then you can check for validation etc... After the user fills the form and if the mail has been sent successfully you can redirect him to sendmail.php page (which you can make html page also and just display the message) and In your request.php file you can keep the code

 

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// you can assign these REQUEST in variables for your ease too...
if (empty($_REQUEST['title']))
echo $_REQUEST['title'];
$msg = "Please enter title <Br>";
if (empty($_REQUEST['email']))
$msg .= "Please enter email <Br>";
if(!ereg("[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]", $_REQUEST['email']))
$msg .= "Email not valid <Br>";
if (empty($_REQUEST['name']))
echo $_REQUEST['name'];
$msg .= "Please enter your name <Br>";
if (empty($_REQUEST['telephone']))
$msg .= "Please enter an telephone <Br>";
if (empty($_REQUEST['address']))
$msg .= "Please enter address <Br>";
if (empty($_REQUEST['lastname']))
$msg .= "Please enter last name <Br>";

// this will check if there is error or not if there is no error then send the mail
if (empty($msg)) 
	{
	// in this way you can add other and send the mail
	$message = "Title :".$_REQUEST['title']."\r\n"."Name :".$_REQUEST['name'];

	$from = "From: ".$email."\r\n";
	$to = '[email protected]';

	mail($to, $subject, $message, $from);
	echo "Mail Sent Succesfully";
	// after the mail is send redirect the user to Other page or you can just display the message here 
	}
	else 
	{
	echo "There are some errors.";
	}

}

?>

 

 

code looks like this, no idea if that right

 

 <?php
		if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
}
if(empty($firstname) || empty($visitormail) || empty($mobile) || empty($cost )) {
echo "<h2></h2>\n";
}
$to = '[email protected]';
$todayis = date("l, F j, Y, g:i a") ;

$attn = $firstname ; 
$subject = "Valuation form from Homes Bought Today" ; 
$notes = stripcslashes($notes); 

$message = " $todayis [EST] \n
From:$_POST['firstname'] 
Title:$_POST['title'] 
Name:$_POST['firstname'] 
Address1:$_POST['address1'] 
Address2:$_POST['address2'] 
Postcode:$_POST['postcode'] 
Telephone:$_POST['telephone'] 
Mobile:$_POST['mobile'] 
Email:$_POST['visitormail'] 
Type of Property:$_POST['proptype'] 
Is your property on the market?:$_POST['propmarket'] 
If so Which Agent?:$_POST['agent'] 
How Much: $_POST['cost'] 
Do you wish to stay as a tenant?: $_POST['tenant']
From: $_POST['firstname'] ($_POST['visitormail'])
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From:$_POST['visitormail]\r\n";
mail($to, $subject, $message, $from);


?>

 

Sorry to say your code is not good, you cannot just modify it. You should change the request.html file to request.php file and keep the code in the same page and after the mail is sent you can redirect the user to show the message you have shown . Thank you ..........

how do i link the form to the code (ie <form action=?>) and where do i place the php code in the request.php? thanks for this

 

n~ link=topic=166708.msg734473#msg734473 date=1194456533]

First of all I suggest you to rename your request.html file to request.php file (where the form is) , then you can check for validation etc... After the user fills the form and if the mail has been sent successfully you can redirect him to sendmail.php page (which you can make html page also and just display the message) and In your request.php file you can keep the code

 

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// you can assign these REQUEST in variables for your ease too...
if (empty($_REQUEST['title']))
echo $_REQUEST['title'];
$msg = "Please enter title <Br>";
if (empty($_REQUEST['email']))
$msg .= "Please enter email <Br>";
if(!ereg("[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]", $_REQUEST['email']))
$msg .= "Email not valid <Br>";
if (empty($_REQUEST['name']))
echo $_REQUEST['name'];
$msg .= "Please enter your name <Br>";
if (empty($_REQUEST['telephone']))
$msg .= "Please enter an telephone <Br>";
if (empty($_REQUEST['address']))
$msg .= "Please enter address <Br>";
if (empty($_REQUEST['lastname']))
$msg .= "Please enter last name <Br>";

// this will check if there is error or not if there is no error then send the mail
if (empty($msg)) 
	{
	// in this way you can add other and send the mail
	$message = "Title :".$_REQUEST['title']."\r\n"."Name :".$_REQUEST['name'];

	$from = "From: ".$email."\r\n";
	$to = '[email protected]';

	mail($to, $subject, $message, $from);
	echo "Mail Sent Succesfully";
	// after the mail is send redirect the user to Other page or you can just display the message here 
	}
	else 
	{
	echo "There are some errors.";
	}

}

?>

 

 

managed with your guys help to sort it out (thanks neo especially for giving me the code)

 

kept the request.html and used the sendemail.php to teh code that neo posted above and works fine!

 

thanks guys really appreciate it!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.