Forum Moderators: open

Message Too Old, No Replies

Action attribute for a simple e-mail form

         

Noyd

8:11 pm on Mar 21, 2005 (gmt 0)

10+ Year Member



Ok i have no clue how this thing works never dealt with php.

<form name="form1" method="post" action="">

Now i dont know what to add in the "action" tag. I looked through some pages that used forms and there was a "mail.php" or "mailer.php" file. But i dont know how to make one.
And i read that it isnt recommended to use a "mailto=" script.
appreciate your help

tedster

1:45 am on Mar 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It can be php, or asp, or perl - any kind of SERVER side scripting language that your server supports. There are lots of such scripts available for free (just use a search engine) once you know which technology your hosting supports. And the good ones usually have decent 'readme' documentation to get you set up relatively quickly - the basic script is there and you just change this and that to support your specific situation.

rocknbil

5:08 pm on Mar 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just to add a few cents. :-)

When you submit a form, the data is encoded by the browser and processed as a single stream sent to the server. This means special characters are changed; a space, for example, is turned into a %20.

You don't use mailto in a form action because the encoded string is exactly what you get in the email, something like

email=whatever@wherever.com&subject=Welcome%20to%20my%20nightmare&message=Hello%20this%20is%20my%20message

Otherwise known as "gobbledygook."

So as tedster said, the usual action of a form is a server-side processor of some sort to decode the data and organize it in some human-legible format

Subject: Welcome to my nightmare
Email: whatever@wherever.com
Message: Hello this is my message

By any server-side language, the data is decoded, checked for malicious characters, formatted, sometimes even stored in a server database, then emailed on to its destination.

Do a search for perl or php tutorials to get started, the mailer is usually the first server-side project that draws people into programming.

Noyd

1:58 am on Mar 24, 2005 (gmt 0)

10+ Year Member



Well thx alot for the help so far.
I found a php but its not workin right.

<Sorry, no personal URLs.
See Terms of Service [webmasterworld.com]>

i used "action=mail.php" and im quit sure its right this way since i saw it in the sourcetxt of other sites. But it trys to open "mail.php" as a source. I dont know what i doing wrong here. Any ideas?
And if you need the php i can add it but im sure that the php file is right.

[edited by: tedster at 2:30 am (utc) on Mar. 24, 2005]

chriswragg

10:39 am on Mar 24, 2005 (gmt 0)

10+ Year Member



It may be that your server doesn't support PHP. That will sometimes cause the file to open as if the browser wants another program to open it. It's best to post the PHP anyway just so we can check it.

Noyd

6:02 pm on Mar 24, 2005 (gmt 0)

10+ Year Member



<?php

//variables (change these)

$youremail = "contact@noyd.net";
// your email address

$subject = "Contact";
// the subject of the email

$thankyou = "/contact02.html";
// thank you page

// don't change anything else

if($email == ""){
?>
<body bgcolor="#55A3DC">
E-mail Has Been Sent.<br/>
<?php
}elseif($name == ""){
?>
No name added. Please go back.<br/>
<?php
}elseif($message == ""){
?>
No message added. Please go back.<br/>
<?php
}else{

$msg = ereg_replace("\\\'", "'", $message);
$msg = ereg_replace('\\\"', "\"", $msg);
$message1 = "from: $name\nemail: $email\nmessage:\n$msg1";

mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");
?>
<meta http-equiv="refresh" content="0; url=<?echo $thankyou;?>"">
<?php
}
?>

Noyd

6:10 pm on Mar 24, 2005 (gmt 0)

10+ Year Member



Seems like u was right chris ... i googled and found out that the server doesnt support php.
I read the faqs from the server and it says that they doent support CGI-scripts. Are Php, perl etc. cgi-script?
Sorry bout those question but im new to this whole scripting thing

chriswragg

8:01 pm on Mar 24, 2005 (gmt 0)

10+ Year Member



The easiest way to check if your server supports PHP is to create a PHP file with ONLY the following lines of code:

<?
phpinfo();
?>

Name it phptest.php or something and upload it. When you open the file in your browser, you should either see loads and loads of configuration info about PHP if it is supported, or the page won't work. If this is the case then you could contact you webhost and ask them to install PHP (which is free), or find a new host!

Noyd

8:30 pm on Mar 24, 2005 (gmt 0)

10+ Year Member



^i tried what you said ... but when i open the file in my browser it asks me if i want to download it.

<Again, no personal URLs.
See Terms of Service [webmasterworld.com]>

[edited by: tedster at 8:32 pm (utc) on Mar. 24, 2005]

chriswragg

9:00 pm on Mar 24, 2005 (gmt 0)

10+ Year Member



This means that your web host doesn't support PHP.

Noyd

9:11 pm on Mar 24, 2005 (gmt 0)

10+ Year Member



^Thx alot for your help . really appreciate it