E-mail form problem


#1

Hi everyone!
I'm sorry my English is bad.
I have a problem with my e-mail form.
When I am trying to write feedback e-mail from my web, the name and message in fields stay grey. Like a "placeholder text" and I can't send them.
But If I chose them from suggestion box from my browser the form work correct!

Where is the problem???

There are some pics...

Thanks!


#2

In the first image they seem to be disabled.
Do you have a link where we can see this problem in action?


#3

Here is the picture:

https://drive.google.com/open?id=145fPXCuRjt3R1p6PA9RpCRy2FbBLm3Qh


#4

I think what @James_Hibbard wanted was a link to a live page, or at least the code from the page.


#5

Yup. Can't really tell much from a picture.


#6

<div class="contact_form_area">
                            <form id="contactForm" class="contact-form">
                                <input type="hidden" style="display:none;" name="from" value="dtheeeeeerv@gmail.com" />
                                <p>
                                    <span class="form-control-wrap">
                                        <div class="form-left"><input type="text" name="name" value="" size="40" class="required" placeholder="Full Name" /></div>
                                        <div class="form-right"><input type="email" name="email" value="" size="40" class="required" placeholder="Email" /></div>
                                    </span>
                                </p>
                                <p><span class="form-control-wrap"><textarea name="your-message" cols="40" rows="10" class="contact-textarea required" placeholder="Message"></textarea></span></p>
                                <p><input type="submit" value="Send" class="contact-submit submit"></p>
                                
                            </form>
                            <p class="formOK">ok</p>
                            <p class="formNOK">error</p>
                            <p class="sending"><span>send...</span></p>
                    </div>

and .php file:
get the data from the form

<?php


	$name = $_POST['name'];
	$message = $_POST['message'];
	$email = $_POST['email'];
	$from = $_POST['from'];

	$to = "$from";
	$subject = 'My WEB';
	$headers = "From: $email";
	$body = "Name: $name<br/> Message: $message";
	
	//send
	$reply = mail($to, $subject, $body, $headers);
?>

#7

I don't see anything obvious in the code posted, other than the absence of a method and action in the form element, which would affect only the post processing of the form. And the absence of labels on the inputs which may affect accessibility in some way.
Is there any additional code that may be affecting things, such as CSS or javascript?

[aside]

A hidden input does not need display none to hide it, it won't display by default.
But really, if you are using this to hide your email address from spammers, it is not really hidden because it's visible in the source code.
To hide it, it would be better defined in the PHP where users can't see it:-

$to = 'mayname@example.com' ;

[/aside]


#8

Please be warry the PHP Mail() code is no longer a safe method as there has been evidence of hackers blacklisting your email address to a point where large providers such as Gmail and Yahoo consider this as spam and prevents user from sending anything.

https://blog.ripstech.com/2017/why-mail-is-dangerous-in-php/

PHPMailer has become very popular in has become more simple to use...

and yes the use of adding your email to html side can be seen with source codes so there has been uses where they captcha or simply hidding your email inside the php section since spam bots can not read php as it is not from end developement but there is also uses where javascript that can be used its basically depends on how you implement your code.

also remove unneccessary code such as the blank value="".

please also validate your code on the php side such as checking for blank input fields and the correct characters for example the email has its own validate on but anyone can use a bogus email address so you need to send a request to check if the email address exists or the text field shouldnt be able to contain content such as </>"' etc only text.

and simply validate the message to also not contain those html characters since thats what makes it prone to hacking unless your making an email related topic with those codes consider convert those elements into just visible text there is alot to consider when using php mail I know the frustration lol.

anyway a good start but try to avoid using php mail() go for phpmailer and the other php coders.


closed #9

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.