Jump to content

Contactus Form


Chikwado

Recommended Posts

The error seems to be here:

<script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>

If you check the logs, it displays an error saying it could not retrieve the page.

 

Are you using a custom script or a third party script?

 

It seems like http://stats.hosting24.com/count.php loads fine if you access it with your web browser, so I'm wondering if they disallow external websites to access this page, or if you yourself have it setup as such on accident.

 

-Chris

Edited by Christopher.Burkhouse
Link to comment
Share on other sites

Are there a modify options for it, Or do I have to contact the hosting company to take a look at it?.

For what? What is "it"?

The error seems to be here:

That's just tracking code for the free web host, they inject the script tag at the end of the page to track usage or whatever.
Link to comment
Share on other sites

@justsomeguy

Oh you're right lol. I was a bit tired and missed the obvious comments.

 

@Chikwado

I forgot to mention, regardless of whether it's a custom or premade script, you're providing us with nothing here. We'd need to be able to see form_handler.php in a case where there are no errors. You're not even telling us what the expected results are. Is it supposed to echo text? Is an email actually sent but no text displayed? We need details in order to help. The best way to do this would be by providing your the PHP code in form_handler.php so we can see what's going on, and help from there, unless I'm misunderstanding the situation.

 

-Chris

Link to comment
Share on other sites

The following are the php code:

<!DOCTYPE html>
<html>
<body>
<?php
//Recipient
recipient = "info@chiquado.site90.net";
//Get user input
$name = $_GET["fname"];
$name = $_GET["lname"];
mail($recipient, $fname, $lname);
echo "mail sent";
?>
</body>
</html>
Although my form has 4 input field with one radio button. I was testing 2 field. The above php has extension as:
form_handler.php
html form action has:
form_handler.php
Then if html code is needed I will show it. Thanks. Edited by Chikwado
Link to comment
Share on other sites

Look at the manual for the mail function:http://php.net/manual/en/function.mail.phpThe required parameters are to, subject, and message.

$name = $_GET[fname];$name = $_GET["lname"];
One of those is quoted, and one of them is not. And you're saving both in a variable called $name.
mail($recipient, $fname, lname);
You have no variables called $fname or $lname (and you left out the $).Add this to the top of your PHP code:
ini_set('display_errors', 1);error_reporting(E_ALL);
Link to comment
Share on other sites

If the documentation is confusing, then also look at the samples provided. They are very clear. If it still doesn't make sense, let us know which part you're stuck on. A big part of learning PHP is using the documentation and resources available, which justsomeguy gave you a direct link to. Also, note that you can do the following:

if(mail($e,$s,$m))    echo 'Email sent successfully';else    echo 'Error sending email.';

As opposed to assuming it was sent successfully just because it didn't error out.

As stated, mail returns true if successful, otherwise returns false.

Link to comment
Share on other sites

I am sorry for all that mistake, It's just the way I am working hard over it without progress. This is the code:

<!DOCTYPE html>
<html>
<body>
<form method="POST"
action="<?php echo $_SERVER
['PHP_SELF']; ?>">
FirstName:<input type="text" name="fname">
LastName:<input
type="text" name="lname">
Email:<input type="text" name="email">
Phone:<input type="text"
name="phone">
Message:<input type=
"textarea" id="txt"  name="message">
Male:<input type="radio"
name="radioa">
Female:<input type=
"radio" name="radiob">
<input type="submit"
value="Submit">
</form>
<?php
$to = 'info@chiquado.site90.net';
if($_SERVER["REQUEST_METHOD"] =="POST")
{
$anameone = $_POST['fname'];
$bnametwo = $_POST['lname'];
$cnamethree = $_POST['email'];
$dnamefour = $_POST['phone'];
$enamefive = $_POST['message'];
$fnamesix = $_POST['radioa'];
$gnameseven = $_POST['radiob'];
if(mail($to, $subject, $message)) {
echo 'mail sent';
}else{
echo 'mail not sent';
}
}
</body>
</html>
Edited by Chikwado
Link to comment
Share on other sites

Why are you assigning one variable ($name) to all the fields. Can you name each input field differently.

Link to comment
Share on other sites

I don't know how you're pasting your code in here, but it's a lot easier to read when you only have 1 code box instead of 1 box per line.

<!DOCTYPE html><html><body><form method="POST"action="<?php echo $_SERVER['PHP_SELF']; ?>">FirstName:<input type="text" name="fname">LastName:<inputtype="text" name="lname">Email:<input type="text" name="email">Phone:<input type="text"name="phone">Message:<input type="textarea" id="txt"  name="message">Male:<input type="radio"name="radioa">Female:<input type="radio" name="radiob"><input type="submit"value="Submit"></form><?php$to = 'info@chiquado.site90.net';if($_SERVER["REQUEST_METHOD"] =="POST"){$anameone = $_POST['fname'];$bnametwo = $_POST['lname'];$cnamethree = $_POST['email'];$dnamefour = $_POST['phone'];$enamefive = $_POST['message'];$fnamesix = $_POST['radioa'];$gnameseven = $_POST['radiob'];if(mail($to, $subject, $message)) {echo 'mail sent';}else{echo 'mail not sent';}}</body></html>
When you call the mail function you're trying to send variables called $subject and $message, but they aren't defined. You aren't doing anything with the data from the form either.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...