FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Simple Html Php Form not working
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Simple Html Php Form not working [message #178830] Fri, 10 August 2012 19:49 Go to next message
bpascal123 is currently offline  bpascal123
Messages: 3
Registered: August 2012
Karma: 0
Junior Member
Hi,

I'm new to Php, I understand basic coding things related to variable, loops, functions... more client side. I would like a contact or comments form on my website http://multiskillz.tekcities.com

The page where the form is is there http://multiskillz.tekcities.com/index99_comments.php or link comment on the left window.

I have used the php code from this web site http://www.freecontactform.com/email_form.php

I made a few changes since I don't want exactly the same thing:

Below is the html (index99_comments.html)

<div id="gate_A_resize3_comments"><p id="blackboard"></p>

<form method="post" name="contact_form" action="contact-form-handler.php">
<br><br><br><br>
Your Name:
<input type="text" name="name">
<br><br><br><br>
Email Address:
<input type="text" name="email">
<br><br><br>
Message:
<textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea>
<input type="submit" value="Submit"> <a href="email_form.php"></a>
</form>
</div>


And below the php related php code (email_form.php)


<?php

if(isset($_POST['email'])) {

//EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "pascal(dot)baro(at)hotmail(dot)com";
$email_subject = "Website";

function died($error) {
// your error code can go here
echo "We are sorry, but there were error(s) found in the submitted form. ";
echo "These errors appear below. <br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors. <br /><br />";
die();
}

if (!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['comments'])) {
died('We are sorry, but a field is missing.');
}
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg-match($email_exp, $email_from)) {
$error_message .= 'The email address is not valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp, $name)) {
$error_message .= 'The name does not seem valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The comments does not seem valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";

function clean_string($string) {
$bad = array("content-type", "bcc:", "to:", "cc:", "href");
return str_replace($bad, "",$string);
}
$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";

//create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n".
'X-Mailer: PHP/' .phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->

Thank you for contacting us. We will be in touch with you very soon.

<?php
}
?>


I understand I have to change a few settings on the localhost server for this work locally (I'm using Windows 7 and Xamp). As I want to get quickly to the point, I'm testing it directly online on http://multiskillz.tekcities.com/index99_comments.php and it just keeps failing.

Do I have to change settings on the server as well (batcave or tekcities)?
Or is it something about the code?

Thanks if you can provide any clue or answer.

Pascal
Re: Simple Html Php Form not working [message #178831 is a reply to message #178830] Fri, 10 August 2012 20:15 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 10-08-2012 21:49, bpascal123 wrote:
> Hi,
>
> I'm new to Php, I understand basic coding things related to variable, loops, functions... more client side. I would like a contact or comments form on my website http://multiskillz.tekcities.com
>
> The page where the form is is there http://multiskillz.tekcities.com/index99_comments.php or link comment on the left window.
>
> I have used the php code from this web site http://www.freecontactform.com/email_form.php
>
> I made a few changes since I don't want exactly the same thing:
>
> Below is the html (index99_comments.html)
>
> <div id="gate_A_resize3_comments"><p id="blackboard"></p>
>
> <form method="post" name="contact_form" action="contact-form-handler.php">

read above, when form is submitted, control goes to
"contact-form-handler.php"

and in next line the <a href.....</a> does not make much sence....

> <input type="submit" value="Submit"> <a href="email_form.php"></a>
> </form>
>
> I understand I have to change a few settings on the localhost server for this work locally (I'm using Windows 7 and Xamp). As I want to get quickly to the point, I'm testing it directly online on http://multiskillz.tekcities.com/index99_comments.php and it just keeps failing.
>

yes, you DO need to learn HTML ;)

> Do I have to change settings on the server as well (batcave or tekcities)?
> Or is it something about the code?
>
> Thanks if you can provide any clue or answer.
>
> Pascal
>
Re: Simple Html Php Form not working [message #178833 is a reply to message #178830] Fri, 10 August 2012 21:42 Go to previous messageGo to next message
bpascal123 is currently offline  bpascal123
Messages: 3
Registered: August 2012
Karma: 0
Junior Member
Hi
I had quite a long day so my coding is weak and thus dealing with scripting languages I am not used to is indeed a challenge.

Anyway, I spot the things you've mentioned and else. Now, I get to the page:
"Thank you for contacting us. We will be in touch with you very soon." So, it means the script is working. However, I'm not receiving any messages...should I wait longer? Usually, hotmail is fast at delivering mail.

Please advise
Pascal
Re: Simple Html Php Form not working [message #178837 is a reply to message #178833] Sat, 11 August 2012 07:58 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 10-08-2012 23:42, bpascal123 wrote:
> Hi
> I had quite a long day so my coding is weak and thus dealing with scripting languages I am not used to is indeed a challenge.
>
> Anyway, I spot the things you've mentioned and else. Now, I get to the page:
> "Thank you for contacting us. We will be in touch with you very soon." So, it means the script is working.

No, it means the last part of your code works,

> However, I'm not receiving any messages...should I wait longer? Usually, hotmail is fast at delivering mail.

you should check if hotmail received the message

>
> Please advise
> Pascal

In your code is a line that reads:
@mail($email_to, $email_subject, $email_message, $headers);

The '@' makes sure that you dont see any error messages that could be
the result of the funciton 'mail'.

Thahts why you do NOT know if the message is send, or not...
Re: Simple Html Php Form not working [message #178840 is a reply to message #178837] Sat, 11 August 2012 09:03 Go to previous messageGo to next message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma: 0
Senior Member
On 11/08/12 09:58, Luuk wrote:
> On 10-08-2012 23:42, bpascal123 wrote:
>> Hi
>> I had quite a long day so my coding is weak and thus dealing with scripting languages I am not used to is indeed a challenge.
>>
>> Anyway, I spot the things you've mentioned and else. Now, I get to the page:
>> "Thank you for contacting us. We will be in touch with you very soon." So, it means the script is working.
>
> No, it means the last part of your code works,
>
>> However, I'm not receiving any messages...should I wait longer? Usually, hotmail is fast at delivering mail.
>
> you should check if hotmail received the message

Keep in mind that hotmail (micorosft) spam filter is a pita, and they
will not tell you if the mail was detected as spam, for then it will
never get to your mailbox, only mail that they think may or may not be
spam will end up in the junk mail folder.

Usually mail without a proper mail header will be regarded as spam and
never be delivered to the receiver.


> In your code is a line that reads:
> @mail($email_to, $email_subject, $email_message, $headers);
>
> The '@' makes sure that you dont see any error messages that could be
> the result of the funciton 'mail'.
>
> Thahts why you do NOT know if the message is send, or not...


mail() just returns true or false and even if you get a true result, you
aren't guaranteed that mail will be sent, you will only know it had a
successful connection to the SMTP/sendmail.

--

//Aho
Re: Simple Html Php Form not working [message #178850 is a reply to message #178840] Mon, 13 August 2012 00:13 Go to previous messageGo to next message
bpascal123 is currently offline  bpascal123
Messages: 3
Registered: August 2012
Karma: 0
Junior Member
Thanks all,
This is working, I switched from hotmail to gmail...
Very basic php, I wonder how much secured is it?
Why are there some Php scripts that provide so much controls over what a user can enter (input)??? I would understand this if there is a database somewhere but for such a form...
Thanks again,
Pascal
http://multiskillz.elementfx.com/index99_comments.html
Re: Simple Html Php Form not working [message #178852 is a reply to message #178850] Mon, 13 August 2012 08:16 Go to previous messageGo to next message
Michael Vilain is currently offline  Michael Vilain
Messages: 88
Registered: September 2010
Karma: 0
Member
In article <0c3f85a9-e29c-4edd-9c76-419ce2685bad(at)googlegroups(dot)com>,
bpascal123 <bpascal123(at)gmail(dot)com> wrote:

> Thanks all,
> This is working, I switched from hotmail to gmail...
> Very basic php, I wonder how much secured is it?
> Why are there some Php scripts that provide so much controls over what a user
> can enter (input)??? I would understand this if there is a database somewhere
> but for such a form...
> Thanks again,
> Pascal
> http://multiskillz.elementfx.com/index99_comments.html

I think you need to read up on php and how it works more throughly. It
runs on a remote system (or the local system using a web server with php
linked/added into it). The ability to enter data via the web is a
function of the html <form> tag, not php. What you do with that data
and how secure the environment is depends on the knowledge and skill of
the php programmer.

Injection attacks can be filtered out with the proper screening of data
obtained from a form. There are lots of sites that discuss web site
security. Google them to expand your understanding.

php can run standalone as part of a web server with a database. Or it
can be shared amongst other users with proper permissions or ACLs
security access to the php source code running on the server. Again,
this requires the implementor know enough about the security model of
the environment he's running on. Google is your friend here also.

So some more reading and ask your question again.

--
DeeDee, don't press that button! DeeDee! NO! Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]
Re: Simple Html Php Form not working [message #178872 is a reply to message #178830] Thu, 16 August 2012 23:08 Go to previous message
olivier.ligny is currently offline  olivier.ligny
Messages: 3
Registered: August 2012
Karma: 0
Junior Member
Le vendredi 10 août 2012 21:49:57 UTC+2, bpascal123 a écrit :
> Hi,
>
>
>
> I'm new to Php, I understand basic coding things related to variable, loops, functions... more client side. I would like a contact or comments form on my website http://multiskillz.tekcities.com

Hi, you can try this free service I just launched :
http://www.simple-file-upload.com/
With the 'email' option you don't need any PHP code, you'll receive an automatic email with the user inputs.
It can handle large file uploads, but you can also use the script with no file upload field at all.

Bye
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Create hierarchical tree structure for categories in joomla
Next Topic: Free service to allow large file upload in PHP forms
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 21 21:44:36 GMT 2024

Total time taken to generate the page: 0.02644 seconds