Hi,
I have tried to test my php for ages now but when i test a form and click submit instead of the form data being sent to my email a prompt comes up asing me to open/save the php folder. What do I do?
Thanks,
James
2 3042
You're not providing any information about the code whatsoever. It's impossible to know how to advise you.
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<meta http-equiv="content-type"
-
content="text/html; charset=iso-8859-1" />
-
<title>Emailing Form Data</title>
-
<link rel="stylesheet" type="text/css" href="mainform.css" />
-
</head>
-
<body>
-
<div id="form">
-
<h2>Ordering your new bed</h2>
-
<p>Please fill out the form below to order your new bed. If you have any questions, don't hesitate to <a href="contactform.html">contact us</a>.</p>
-
-
<form method="post" action="emailform.php">
-
<p class="legend">Personal information</p>
-
<fieldset id="personal">
-
<label>Name:</label><input type="text" name="name" size="30" /> <br />
-
<label>Email:</label><input type="text" name="email" size="30" /> <br/>
-
<label>Address:</label><input type="text" name="address" size="30" /> <br />
-
<label>Town/City:</label><input type="text" name="city" size="30" /> <br />
-
<label>State:</label><input type="text" name="state" size="2" maxlength="2" /><br />
-
<label>Zipcode:</label><input type="text" name="zip" size="5" maxlength="5" /> <br />
-
<label>Customer ID:</label><input type="password" name="code" size="8" />
-
</fieldset>
-
-
<p class="legend">Choices</p>
-
<fieldset id="choices">
-
<p id="woodtype"><label>Type of wood:</label><select name="woodtype">
-
<option value="Mahogany">Mahogany</option>
-
<option value="Maplewood">Maplewood</option>
-
<option value="Pine">Pine</option>
-
<option value="Cherry">Cherry</option>
-
</select></p>
-
-
<p id="size"><label>Size:</label><input type="radio" name="size" value="K" />King
-
<input type="radio" name="size" value="Q" />Queen <br />
-
<input type="radio" name="size" value="T" />Twin
-
<input type="radio" name="size" value="S" />Single</p>
-
-
<p id="extras"><label>Extras:</label>
-
<input type="checkbox" name="extras[]" value="foot" />Footboard
-
<input type="checkbox" name="extras[]" value="drawers" checked="checked" />Drawers <br />
-
<input type="checkbox" name="extras[]" value="casters" />Casters <input type="checkbox" name="extras[]" value="nosqueak" />Squeak proofing <br />
-
</p>
-
</fieldset>
-
-
<p class="legend">Suggestions</p>
-
<fieldset id="suggestions">
-
<textarea
-
name="comments" rows="3" cols="40">Please share any comments you have here</textarea>
-
</fieldset>
-
-
<p id="buttons"><input type="submit" value="Order Bed" />
-
<input type="reset" value="Start Over" /></p>
-
-
</form>
-
</div>
-
</body>
-
</html>
-
AND THE PHP CODE -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<title>Emailing Form Data</title>
-
<style type="text/css">
-
code {color:#F00C4D;font-weight:bold;font-size:1.2em}
-
i {color: #6D0CF0}
-
th, td {padding:.1em;border:1px solid blue;text-align:left}
-
</style>
-
</head>
-
<body>
-
-
-
<?php
-
//This is a very simple PHP script that outputs the name of each bit of information (that corresponds to the <code>name</code> attribute for that field) along with the value that was sent with it right in the browser window, and then sends it all to an email address (once you've added it to the script).
-
-
if (empty($_POST)) {
-
print "<p>No data was submitted.</p>";
-
print "</body></html>";
-
exit();
-
}
-
-
//Creates function that removes magic escaping, if it's been applied, from values and then removes extra newlines and returns to foil spammers. Thanks Larry Ullman!
-
function clear_user_input($value) {
-
if (get_magic_quotes_gpc()) $value=stripslashes($value);
-
$value= str_replace( "\n", '', trim($value));
-
$value= str_replace( "\r", '', $value);
-
return $value;
-
}
-
-
-
if ($_POST['comments'] == 'Please share any comments you have here') $_POST['comments'] = '';
-
-
//Create body of message by cleaning each field and then appending each name and value to it
-
-
$body ="Here is the data that was submitted:\n";
-
-
foreach ($_POST as $key => $value) {
-
$key = clear_user_input($key);
-
$value = clear_user_input($value);
-
if ($key=='extras') {
-
-
if (is_array($_POST['extras']) ){
-
$body .= "$key: ";
-
$counter =1;
-
foreach ($_POST['extras'] as $value) {
-
//Add comma and space until last element
-
if (sizeof($_POST['extras']) == $counter) {
-
$body .= "$value\n";
-
break;}
-
else {
-
$body .= "$value, ";
-
$counter += 1;
-
}
-
}
-
} else {
-
$body .= "$key: $value\n";
-
}
-
} else {
-
-
$body .= "$key: $value\n";
-
}
-
}
-
-
extract($_POST);
-
//removes newlines and returns from $email and $name so they can't smuggle extra email addresses for spammers
-
$email = clear_user_input($email);
-
$name = clear_user_input($name);
-
-
//Create header that puts email in From box along with name in parentheses and sends bcc to alternate address
-
$from='From: '. $email . "(" . $name . ")" . "\r\n" . 'Bcc: yourmail@yourdomain.com' . "\r\n";
-
-
-
//Creates intelligible subject line that also shows me where it came from
-
$subject = 'Bed Order from Web Site';
-
-
//Sends mail to me, with elements created above
-
mail ('youremail@yourdomain.com', $subject, $body, $from);
-
-
-
?>
-
-
<p>Thanks for your order! We'll send your bed right away.</p>
-
-
-
</body>
-
</html>
-
Thanks. James
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Joe |
last post by:
In the following code, page1.asp is inside the frame of main.html.
When the user click submit button in page1.asp, it will submit the for
and open a new window called page2.asp. When the user...
|
by: Timothy Madden |
last post by:
Hello all
I have a little problem and I hope it is simple.
I have a form on my page and I have to open a pop-up window with
the page serverd after the form submit. I know I can compose the URL...
|
by: besbello |
last post by:
Hi all,
I want to submit a form when the user closes the browser, to keep a
count of the number of users accesing my application at each moment. To
do this, I use the onbeforeunload() event, that...
|
by: palgrave |
last post by:
Hi,
How do you create an html link from a web page to a read-only excel
spreadsheet without the browser asking if the user wants to open it or
save it?
|
by: jongyoo |
last post by:
Hey guys, I'm having some trouble scripting someway where I can submit a form and open up a new window at the same time, so I would have two windows open. Thanks
| |
by: Server Control |
last post by:
Hi,
I am exporting my datagrid to Excel using the standard Export to Excel
Method using :
dg.RenderControl(). and
Page.Response.AddHeader("Content-Disposition", "attachment;filename=" +...
|
by: Sheau Wei |
last post by:
i would like to create a prompt up messsage in when submit a form, how to make it?
|
by: Harshpandya |
last post by:
Hi all,
I am working on the form in which you fill out the whole PHP form and e mail that details to someone. It is working fine. But now i want to send the same form to be sent to different...
|
by: V S Rawat |
last post by:
using Javascript, I am opening a web-based url in a popup window.
MyWin1=Window.Open(url, "mywindow")
There is a form (form1) in the url in that popup window, I need to
submit that form.
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |