• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

HTML form help.

Status
Not open for further replies.
Okay, I've got a form on my site for stat collection (I'm hosting several Blizzard related things... Such as guides on how to host), and I've got it to email me the information set in forms.

Now, I don't know much about HTML... I had to ask someone to make this script for me, but could someone tell me what I should add to make it save the information on a .html file on the server?

Code:
<form action="mailto:"> <!-- BE SURE TO CHANGE EMAIL HERE! -->

Username: <input type="text" size="30" maxlength="40" name="name"><br />
Server: <select name="server">
<option>Azeroth</option>
<option>Lordaeron</option>
<option>Northrend</option>
<option>Kalimdor</option>
</select><br />
Client: <select name="client"> <!-- YOU CAN ADD MORE OPTIONS OR EDIT THEM WITH THE SAME FORMAT -->
<option>Starcraft</option>
<option>Starcraft: Brood War</option>
<option>Diablo</option>
<option>Diablo 2</option>
<option>Diablo 2: LoD</option>
<option>Warcraft III: Reign of Chaos</option>
<option>Warcraft III: The Frozen Throne</option>
<option>Warcraft II: Battle.net Edition</option>
</select><br />
<input type="submit" value="Send">
</form>

Thanks for any help
- TheLifelessOne
 
Level 22
Joined
Feb 26, 2008
Messages
891
mailto:youremailhere

So, for me:

mailto:[email protected]

That's what needs to go there. And then save it as a .html file and upload to the server's web root (or some folder where you want to place it). You should then be able to access the page by the file name in a browser. (With the domain name in front, of course.)
 
@Elfsilver Lord
I'm using 000webhost as a host, and either the online FTP or FileZilla for my FTP.
Whichever one is easiest at the time... I'm not always on my personal computer.

@Ghan 04

Huh....
The problem was when I used the <form action="mailto:"> tag, it would open an email program, which I don't want to happen.
All I want it to do is store the form information somewhere so I can look at it later.
 
Level 11
Joined
Feb 14, 2009
Messages
884
You don't need Javascript for a mailing form. You can do this in PHP/ASP or by using a Perl CGI script.

PHP:
<?php
function injectionblock ($field)
{
$field = filter_var($field, FILTER_SANITIZE_EMAIL);

If (filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
else
    {
    return FALSE;
    }
}

If (isset($_REQUEST["email"]))
    $mailcheck = injectionblock($_REQUEST["email"]);

if ($mailcheck==FALSE)
    {
    echo "Data not valid!";
    }
else
    $email = $_REQUEST["email"];
    $subject = $_REQUEST["subject"];
    $message = $_REQUEST["message"];
    mail ([email protected]", "Subject: $subject", $message, "From: $email");
    echo "Mail sent";
    }
}

?>

Now, all you have to do is to CnP this code to a file named, for example, formmail.php. Then, use

HTML:
<form method="POST" action="formmail.php">
and name your message, email and subject textboxes as you see them on the PHP script ("email", "message", "subject")

This is just a generic e-mail form. I don't know how exactly you can submit the option buttons though :/

The mailto protocol runs the user's default e-mail client and allows him/her to send the email from there. It doesn't send the email using the form.
 
Level 8
Joined
Aug 12, 2008
Messages
424
And then save it as a .html file and upload to the server's web root (or some folder where you want to place it). You should then be able to access the page by the file name in a browser. (With the domain name in front, of course.)
The "name" argument is the name of the file it's to be saved in, isn't it? That or the variable name, I don't remember which anymore.
 
CSS is a way of formmating text.
Example:
p
{
font-family: Arial;
font-size: 12;
color: White;
}
That's your basic CSS syntax.
I don't know much CSS, but that's pretty much all there is to it.

I know HTML can't save this, that's why I'm asking for help.
JavaScript is confusing to me, an PHP is too advanced or me to learn at the moment, else I'd code this myself.

Anyway, the only problem I've had is it loads an email program.
All I want it to do is save that information on a text file in my server.
If that's not possible, email works too.
 
Level 11
Joined
Feb 14, 2009
Messages
884
Thanks.
Tried it though, and I got this: Parse error: syntax error, unexpected '@' in /home/wchaveni/public_html/lifeless/formmail.php on line 27

I don't understand... There's no '@' in line 27. Are you trying to run this in your own computer? Because if you do, it won't work unless you have a PHP server installed. Try uploading it in your host and try again.
 
Level 8
Joined
Aug 12, 2008
Messages
424
The HTML form inserts data directly into the server. Hmm, try the following tag:
HTML:
<form action="mailto" method="post">

<!--If you still have trouble, Try the get method-->

<form action="mailto" method="get">
If that doesn't work, then you may need to use PHP.
 
Level 11
Joined
Feb 14, 2009
Messages
884
The HTML form inserts data directly into the server. Hmm, try the following tag:
HTML:
<form action="mailto" method="post">

<!--If you still have trouble, Try the get method-->

<form action="mailto" method="get">
If that doesn't work, then you may need to use PHP.

The GET method is not good, as data are visible in the address bar. Besides, he has already tried the mailto protocol and it's not what he wants...
 
Level 8
Joined
Aug 12, 2008
Messages
424
I know for a fact that the get method isn't good, hence I offered the post method first.
If it isn't what he wants, then it's out of the hands of HTML.
 
Level 15
Joined
Nov 1, 2004
Messages
1,058
PHP:
<?php
function injectionblock ($field)
{
$field = filter_var($field, FILTER_SANITIZE_EMAIL);

If (filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
else
    {
    return FALSE;
    }
}

If (isset($_REQUEST["email"]))
    $mailcheck = injectionblock($_REQUEST["email"]);

if ($mailcheck==FALSE)
    {
    echo "Data not valid!";
    }
else
    $email = $_REQUEST["email"];
    $subject = $_REQUEST["subject"];
    $message = $_REQUEST["message"];
    mail ([email protected]", "Subject: $subject", $message, "From: $email");
    echo "Mail sent";
    }
}

?>
There's a syntax error on the line with mail(): please add a starting quote before [email protected].

Also, you need to sanitize your form input because there's a definite mail header injection/splitting vulnerability in the code, otherwise.
 
Level 11
Joined
Feb 14, 2009
Messages
884
There's a syntax error on the line with mail(): please add a starting quote before [email protected].

Also, you need to sanitize your form input because there's a definite mail header injection/splitting vulnerability in the code, otherwise.

Duh, goddam typos! Doesn't injectionblock stop malicious code injection, 'cause I think it does...
 
Level 8
Joined
Aug 12, 2008
Messages
424
Samuraid just told you that
PHP:
<?php
function injectionblock ($field)
{
$field = filter_var($field, FILTER_SANITIZE_EMAIL);

If (filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
else
    {
    return FALSE;
    }
}

If (isset($_REQUEST["email"]))
    ($mailcheck = injectionblock($_REQUEST["email"]);

if ($mailcheck==FALSE)
    {
    echo "Data not valid!";
    }
else
    $email = $_REQUEST["email"];
    $subject = $_REQUEST["subject"];
    $message = $_REQUEST["message"];
    mail ([email protected]", "Subject: $subject", $message, "From: $email");
    echo "Mail sent";
    }
}

?>
is the the correct coding.
 
Level 8
Joined
Aug 12, 2008
Messages
424
PHP:
<?php
function injectionblock ($field)
{
$field = filter_var($field, FILTER_SANITIZE_EMAIL);

If (filter_var($field, FILTER_VALIDATE_EMAIL))
    {
    return TRUE;
    }
else
    {
    return FALSE;
    }
}

If (isset($_REQUEST["email"]))
    ($mailcheck = injectionblock($_REQUEST["email"]);

if ($mailcheck==FALSE)
    {
    echo "Data not valid!";
    }
else
    $email = $_REQUEST["email"];
    $subject = $_REQUEST["subject"];
    $message = $_REQUEST["message"];
    mail ("[email protected]", "Subject: $subject", $message, "From: $email");
    echo "Mail sent";
    }
}
Missed that. That's what text editors are for.
 
Status
Not open for further replies.
Top