
01-07-06, 02:27 AM
|
|
Newbie Coder
|
|
Join Date: Dec 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
submit form in php
I have created a form in html but i now need it in php, becuase my website host is php supported only, can anyone advise me on how to have this same form in php, Thankyou
<html>
<head><script LANGUAGE="JavaScript">
<!-- Begin
function getCookie(name){
var cname = name + "=";
var dc = document.cookie;
if (dc.length > 0) {
begin = dc.indexOf(cname);
if (begin != -1) {
begin += cname.length;
end = dc.indexOf(";", begin);
if (end == -1) end = dc.length;
return unescape(dc.substring(begin, end));
}
}
return null;
}
function setCookie(name, value, expires) {
document.cookie = name + "=" + escape(value) +
((expires != null) ? "; expires=" + expires.toGMTString() : "")
+ "; path=/";
}
function setName() {
var expdate = new Date ();
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
var prompt=i = document.Mail.name.value;
setCookie("name", i, expdate);
}
function getName() {
if(getCookie("name") != null) {
document.Mail.Name.value = getCookie("emailname");
}
}
function getInfo() {
var now= new Date();
document.Mail.Info.value = "Browser: " + navigator.userAgent;
document.Mail.Info.value += "Date:" + now;
}
function checkMultiple() {
if (getCookie("emailsent") == 'true') return true;
else return false;
}
function process() {
setCookie("emailsent", "true");
with (document.Mail) {
if (Subject.selectedIndex == 1) action = "mailto:my@email.com?subject=TJS - Comment";
else if (Subject.selectedIndex == 2) action = "mailto:my@email.com?subject=TJS - Question";
else if (Subject.selectedIndex == 3) action = "mailto:my@email.com?subject=TJS - Suggestion";
else if (Subject.selectedIndex == 4) action = "mailto:my@email.com?subject=TJS - Broken Link";
else action = "mailto:my@email.com?subject=TJS - Other";
}
}
function formCheck() {
var passed = false;
with (document.Mail) {
if (Subject.selectedIndex == 0) {
alert("Please pick a subject.");
Subject.focus();
}
else if (Name.value == "") {
alert("Please inlcude your name.");
Name.focus();
}
else if (checkMultiple()) {
if (confirm("You just sent an e-mail from this form, are you sure you want to send another?")) {
process();
passed = true;
}
}
else {
process();
passed = true;
}
}
return passed;
}
// End -->
</script>
<title></title><!--content start-->
<table WIDTH="50%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
<tr>
<table width="1" border="0" cellspacing="0" cellpadding="0">
<tr>
<th bgcolor="#99CCFF" scope="col"><form NAME="Mail" ACTION="mailto:my@email.com?subject=TJS - Form"
METHOD="POST" ENCTYPE="text/plain" onSubmit="return formCheck();">
<table width="878" BORDER="0" CELLPADDING="10" CELLSPACING="0">
<tr>
<td width="161"><span class="style86">* Name:
</span> <input TYPE="text" NAME="Name" onChange="setName()" size="20">
</td>
<td width="144"><span class="style86">*Phone:
</span> <input TYPE="text" NAME="Phone" onChange="setName()" size="20">
</td>
<td width="120"><span class="style86">*Email:
</span> <input TYPE="text" NAME="Email" onChange="setName()" size="20">
</td>
<td width="120"><span class="style86">*Website URL:
</span> <input TYPE="text" NAME="Website URL" onChange="setName()" size="20">
</td>
<td width="233" ALIGN="RIGHT" valign="top"> <div align="left"><span class="style86">*Upload Photo/s & Logo
<input type="file" name="user_file">
</span></div></td>
</tr>
<tr>
<td COLSPAN="2" valign="top"><p><span class="style86"> Listing: </span></p>
<p><span class="style86">
<select NAME="Subject" size="1">
<option SELECT>Type of Advertising Required</option>
<option>1. Fried Rice - 1 Year</option>
<option>2. Eat bacon - 6 Months</option>
<option>3. Salty Fish - 3 Months</option>
<option>4. Sloppy Pizza - 3 Months</option>
<option>5. Sticky Chips - 1 Year</option>
</select>
</span><br>
</p></td>
<td colspan="3" align="left" valign="top"><p class="style86">Description: (Max 150 Letters) </p>
<p class="style86">
<textarea NAME="Comments, Suggestions" COLS="50" ROWS="6">
</textarea>
</p></td>
</tr>
</table>
<div align="center">
<center>
<table>
<tr>
<td align="center"><input TYPE="submit" VALUE="Send">
<script LANGUAGE="JavaScript">
<!-- Begin
getInfo();
getName();
// End -->
</script></td>
</tr>
</table>
</center>
</div>
</form></th>
</tr>
</table>
</td>
</tr>
</table>
<!--content stop-->
</body>
</html>
</form>
</TD>
</TR></TBODY></TABLE></P>
<P align=center> </P>
</TD>
</TR>
<TR>
<TD vAlign=top align=left height=460>
<TABLE id=Table3 borderColor=#ffffff height="100%" cellSpacing=0
cellPadding=0 width="100%" border=0 wsc_noborder>
<TBODY>
<TR>
<TD id=Section4 vAlign=top align=right height=30><p> </p>
<p> </p>
</TD></TR>
<TR>
<TD id=Section5 vAlign=bottom align=center width="100%" height=30>
<p><SPAN>
</SPAN></p>
<p> </p>
<P align=center> </P>
</TD>
</TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
</BODY></HTML>
|

01-07-06, 03:16 AM
|
 |
Community VIP
|
|
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
By design, all web servers server HTML, this is the language that allows content to be published and delivered to web Browsers. PHP is just a script language that can be integrated with most (probably all) web servers. If your existing web page/submit form does not work it is not because it needs to be written in PHP.
Submit forms that make use of PHP code are actually HTML forms that typically call a PHP script file as the submit action.
Actually, your code looks familiar. If there is an issue that is causing your mailto: submit action to not work, it does not have anything to do with PHP or non-PHP.
If you wish to use a "form to email" PHP script to replace your mailto: submit action, this is quit simple. There are probably a hundred or more scripts that do this that can be found in the form processor category under PHP on hotscripts.com. Take a look here - http://www.hotscripts.com/PHP/Script...ors/index.html
|

01-09-06, 12:22 AM
|
|
Newbie Coder
|
|
Join Date: Dec 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok to be honest i have had a look at Form scripts in Hotscripts.com as you have suggested and i am not interested in nearly all of them.
I am intersted in is my existing script i already have but you may be able to suggest a way to implement some of this code i found to make it work,
Your help is much apreciated.
<html>
<head>
<title>DynaForm</title>
</head>
<body>
<form action="dynaform.php" method="POST">
<input type='hidden' name='rec_mailto' value='myemail@mysite.com'>
<input type='hidden' name='rec_subject' value='New DynaForm Email'>
<input type='hidden' name='rec_thanks' value='thanks.html'>
Name<br><input type='text' name='Name'><br><br>
Email<br><input type='text' name='Email'><br><br>
Comments<br><input type='text' name='Phone'><br><br>
Address<br><input type='text' name='Comments'><br><br>
<input type='submit' value='Submit'>
</form>
</body>
</html>
(also i will have ofcourse have my file in the same folder as dynaform.php file)
|

01-10-06, 02:21 AM
|
|
Newbie Coder
|
|
Join Date: Dec 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Cmon,
I have alot of Views and i have also shown a code in public that other people can use and have probably done so already,
i just need something in return, some help on how to implement the 2 sets of codes to make them work in php,
someones help would be much apreciated, thankyou
|

01-10-06, 08:54 AM
|
 |
Aspiring Coder
|
|
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
On the page where it submits to..
First, make sure the form has been submitted.. (Let this be the submit button)
if (isset($_POST['submit']))
{
}
then
$_POST['form_input_name_goes_here'] to call each form element, then with php you can process and verify data..
|

01-11-06, 12:14 AM
|
|
Newbie Coder
|
|
Join Date: Dec 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
so,
the send button i already have is <input TYPE="submit" VALUE="Send">
you say i need to change it to - if (isset($_POST['submit']))
{
}
(but it doesnt seem right?)
then where do i place this?
$_POST['form_input_name_goes_here']
|

01-11-06, 12:44 AM
|
 |
Community VIP
|
|
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Originally Posted by danlew
Ok to be honest i have had a look at Form scripts in Hotscripts.com as you have suggested and i am not interested in nearly all of them.
I am intersted in is my existing script i already have but you may be able to suggest a way to implement some of this code i found to make it work,
Your help is much apreciated.
<html>
<head>
<title>DynaForm</title>
</head>
<body>
<form action="dynaform.php" method="POST">
<input type='hidden' name='rec_mailto' value='myemail@mysite.com'>
<input type='hidden' name='rec_subject' value='New DynaForm Email'>
<input type='hidden' name='rec_thanks' value='thanks.html'>
Name<br><input type='text' name='Name'><br><br>
Email<br><input type='text' name='Email'><br><br>
Comments<br><input type='text' name='Phone'><br><br>
Address<br><input type='text' name='Comments'><br><br>
<input type='submit' value='Submit'>
</form>
</body>
</html>
(also i will have ofcourse have my file in the same folder as dynaform.php file)
|
Using your html form, when the submit button is pressed, it will pass execuition to your dynaform.php file. The values entered in the form fields will be available via the $_POST global variable. For example, you have a "name" field. This can be accessed in PHP using a statement like this -
Examining a couple of PHP scripts on hotscripts.com that process the form data, setup the mail data, and send the email would help point you in the right direction toward writing the code you will need to process your form.
Note: Email header injection is a huge problem and allows spammers to enter their own TO, BCC, SUBJECT, FROM, ... fields in the Email address field on your form and send spam to anyone they want. Here is a link on this subject -
http://securephp.damonkohler.com/ind...mail_Injection
|

01-11-06, 01:01 AM
|
|
Newbie Coder
|
|
Join Date: Dec 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Att: MAB
Your making this sound very complicated,
all i need is this code to work in my site which was originally ok before i changed my host account (from "ASP Windows" ) to ("PHP Linux") <html>
my code form:
<head><script LANGUAGE="JavaScript">
<!-- Begin
function getCookie(name){
var cname = name + "=";
var dc = document.cookie;
if (dc.length > 0) {
begin = dc.indexOf(cname);
if (begin != -1) {
begin += cname.length;
end = dc.indexOf(";", begin);
if (end == -1) end = dc.length;
return unescape(dc.substring(begin, end));
}
}
return null;
}
function setCookie(name, value, expires) {
document.cookie = name + "=" + escape(value) +
((expires != null) ? "; expires=" + expires.toGMTString() : "")
+ "; path=/";
}
function setName() {
var expdate = new Date ();
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
var prompt=i = document.Mail.name.value;
setCookie("name", i, expdate);
}
function getName() {
if(getCookie("name") != null) {
document.Mail.Name.value = getCookie("emailname");
}
}
function getInfo() {
var now= new Date();
document.Mail.Info.value = "Browser: " + navigator.userAgent;
document.Mail.Info.value += "Date:" + now;
}
function checkMultiple() {
if (getCookie("emailsent") == 'true') return true;
else return false;
}
function process() {
setCookie("emailsent", "true");
with (document.Mail) {
if (Subject.selectedIndex == 1) action = "mailto:my@email.com?subject=TJS - Comment";
else if (Subject.selectedIndex == 2) action = "mailto:my@email.com?subject=TJS - Question";
else if (Subject.selectedIndex == 3) action = "mailto:my@email.com?subject=TJS - Suggestion";
else if (Subject.selectedIndex == 4) action = "mailto:my@email.com?subject=TJS - Broken Link";
else action = "mailto:my@email.com?subject=TJS - Other";
}
}
function formCheck() {
var passed = false;
with (document.Mail) {
if (Subject.selectedIndex == 0) {
alert("Please pick a subject.");
Subject.focus();
}
else if (Name.value == "") {
alert("Please inlcude your name.");
Name.focus();
}
else if (checkMultiple()) {
if (confirm("You just sent an e-mail from this form, are you sure you want to send another?")) {
process();
passed = true;
}
}
else {
process();
passed = true;
}
}
return passed;
}
// End -->
</script>
<title></title><!--content start-->
<table WIDTH="50%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
<tr>
<table width="1" border="0" cellspacing="0" cellpadding="0">
<tr>
<th bgcolor="#99CCFF" scope="col"><form NAME="Mail" ACTION="mailto:my@email.com?subject=TJS - Form"
METHOD="POST" ENCTYPE="text/plain" onSubmit="return formCheck();">
<table width="878" BORDER="0" CELLPADDING="10" CELLSPACING="0">
<tr>
<td width="161"><span class="style86">* Name:
</span> <input TYPE="text" NAME="Name" onChange="setName()" size="20">
</td>
<td width="144"><span class="style86">*Phone:
</span> <input TYPE="text" NAME="Phone" onChange="setName()" size="20">
</td>
<td width="120"><span class="style86">*Email:
</span> <input TYPE="text" NAME="Email" onChange="setName()" size="20">
</td>
<td width="120"><span class="style86">*Website URL:
</span> <input TYPE="text" NAME="Website URL" onChange="setName()" size="20">
</td>
<td width="233" ALIGN="RIGHT" valign="top"> <div align="left"><span class="style86">*Upload Photo/s & Logo
<input type="file" name="user_file">
</span></div></td>
</tr>
<tr>
<td COLSPAN="2" valign="top"><p><span class="style86"> Listing: </span></p>
<p><span class="style86">
<select NAME="Subject" size="1">
<option SELECT>Type of Advertising Required</option>
<option>1. Fried Rice - 1 Year</option>
<option>2. Eat bacon - 6 Months</option>
<option>3. Salty Fish - 3 Months</option>
<option>4. Sloppy Pizza - 3 Months</option>
<option>5. Sticky Chips - 1 Year</option>
</select>
</span><br>
</p></td>
<td colspan="3" align="left" valign="top"><p class="style86">Description: (Max 150 Letters) </p>
<p class="style86">
<textarea NAME="Comments, Suggestions" COLS="50" ROWS="6">
</textarea>
</p></td>
</tr>
</table>
<div align="center">
<center>
<table>
<tr>
<td align="center"><input TYPE="submit" VALUE="Send">
<script LANGUAGE="JavaScript">
<!-- Begin
getInfo();
getName();
// End -->
</script></td>
</tr>
</table>
</center>
</div>
</form></th>
</tr>
</table>
</td>
</tr>
</table>
<!--content stop-->
</body>
</html>
</form>
</TD>
</TR></TBODY></TABLE></P>
<P align=center> </P>
</TD>
</TR>
<TR>
<TD vAlign=top align=left height=460>
<TABLE id=Table3 borderColor=#ffffff height="100%" cellSpacing=0
cellPadding=0 width="100%" border=0 wsc_noborder>
<TBODY>
<TR>
<TD id=Section4 vAlign=top align=right height=30><p> </p>
<p> </p>
</TD></TR>
<TR>
<TD id=Section5 vAlign=bottom align=center width="100%" height=30>
<p><SPAN>
</SPAN></p>
<p> </p>
<P align=center> </P>
</TD>
</TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
</BODY></HTML>
Last edited by danlew; 01-11-06 at 01:04 AM.
|

01-11-06, 01:39 AM
|
 |
Community VIP
|
|
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am only stating what everyone who wants to send form data through email needs to do.
This takes you back to your original problem. I searched for your original error message and did not find any definitive cause and since no one responded to that post, no one else has apparently seen this or knows what needs to be done to fix it. One possible reason why no one responded is that most people don't use this method, there are too many external situations that prevent the mailto: action from functioning (such as the user's browser does not have an entry for a valid email client or the user uses web based email and he does not even have an email client configured on his computer.)
The cause of the error you receive can range from - the POST/GET methods have been disabled; there is a firewall that blocks the sending of the post data to the client's browser/email client; you might need to use the GET method instead; you might not be able to include any passed parameter on the end of the mailto: address, such as the subject... Most of the people that read your original post probably assumed that you have already investigated these possibilities...
|

01-11-06, 02:31 AM
|
|
Newbie Coder
|
|
Join Date: Dec 2005
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The Only possibility as i was saying earlier why my script is now not working is becuase i have changed my host account from ASP Windows to PHP Linux and i know its only that for a Fact!
So how do we get around the original form i created in html to work with my new host suppot php Linux only account,
as i say i do not want any other form besides this one.
I know this is a pain but its very fustrating for me too, becuase i now lose business through clients not being able to enter there details and send there information to me.
Your help is apreciated
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|