How to get a web page input datas? - javascript

Am very New to Web Page Development.
In my website i have the help page like Name, Email ID, Contact No, Comment and Submit Button Suppose i entered the data in the help page , then i press submit button means that entered data's should sent to the email account
For Example
Help Page
Name - Raja
Email - raja#gmail.com
Contact - 98763214
Comments - Good web page
Then I pressed Send button means, the above entered data should send to this email account
support#it.com with the same format.
Need Code Help or Script Help

use FormMail
you should set these variables in formmail.pl
#referers = ('yourdomain.com','ip_number');
look at this
and
#recipients = ('^support\#it\.com');
look at this
and
$mailprog = '/usr/lib/sendmail -i -t';
which is the path of sendmail in your system. if you're not sure where is your sendmail path, use the following command at your unix prompt:
which sendmail
This will tell you where sendmail is on your system. If it says it could not find it, just ask your system administrator.
after configured formmail.pl, put it in cgi-bin folder.
here is an example of a form using formmail.pl ( recipient field is required )
<form name="myform" action="http://yourdomain.com/cgi-bin/test.pl" method="GET">
<input type=hidden name="recipient" value="support#it.com">
<input type=textarea name="mytext"/>
<input type="submit" />
</form>
for more information about how to use formmail, go here.

Like Jørn Schou-Rode said, you really need to use a server-side programming language to catch and process the form data. The options are numerous - PHP, ASP, .NET, ColdFusion, Java, Ruby... the list goes on. See http://en.wikipedia.org/wiki/Server-side_scripting as a starting point.
I remember starting out in web development and wanting to do the same thing but you really are now getting into more advanced areas of development (beyond simple client-side HTML/CSS/JavaScript coding).

Related

Make the mail body disabled in mailto js

I'm building a shooping site where the customer is ablee to contact the seller with emails.
I dont want to use backend so I just use Mailto.
now, I have 2 questions:
1) Can I open the client mail with disabled field?
So that he wont be able to change the "To" field (for example)?
I dont want to use "readonly" attribute because there are also fields that the user himself need to fill.
2) Can I send the mail from my code without the customer press "send"?
Thank you guys!
Can I open the client mail with disabled field?
No.
Can I send the mail from my code without the customer press "send"?
No.
If you want to do that, then use server-side code to send the email. You might want to use a backend, but you need one. It can be one you run on your websites server or a third-party service.

How do I get user-inputted information from the website directly to my e-mail?

So I've decided to make a website a few months ago and have then picked up basic HTML, CSS, Javascript and Jquery. Now I want to do two things with my website,
show a user-voted poll somewhere on my website that will update live as the users vote on different optinos.
A form on my website that when the user fill out and click the "submit" button, the form will automatically be forwarded to my desired e-mail address
I've been told to learn PHP because it's suppose to help my problem, but so far I have yet to see how it's going to help me solve the above two problems. Any suggestion on how I can achieve the two things above??
PS: if someone can explain what exactly is PHP, I will also be really grateful. I've been looking up what PHP is and the majority of the responses I get is "it's a server side language", which is not exactly helpful. And if PHP does help me solve the two questions above, how?
PHP standing for Hypertext Preprocessor, is a server side programming language. Taking a look at what you have currently learned (HTML, CSS and Javascript) these are all Client side languages.
The difference is that any processing done by a client side language is done within the browser straight in front of the user's eyes.
A server side language like PHP is used when we want to compile relevant data from sources like a MySQL database, before sending the information to the browser. Meaning it's far more dynamic.
You should start by going through some tutorials, do not use w3schools.com, because I don't believe they teach the best practices and it will probably do you more harm than good in the long run.
A quick google search should lead you to some decent tutorials, however I'd highly recommend http://php.net/manual/en/getting-started.php
PHP is actually a "server side language" (mostly) :)
It means that it allows your web server to be smart, i.e:
load/read data from a database
send emails
generate pages dynamically (instead of just serving static pages)
etc...
Sending mail with PHP is documented here: http://us2.php.net/manual/en/function.mail.php
Basically in your HTML you'll tell your form to be posted to a specific PHP script which is hosted on your web server, e.g:
<form action='send_mail.php'>.....</form>
And this script will retrieve the form data and handle the mail sending, e.g:
<php>
$data = $_POST; // contains the form's input values
mail("foo#mail.com", "Notification mail", "A form has been submitted with some data: ".$data["fieldName"]);
</php>
PHP is exactly what they have told you - a server side scripting language. What that means is that PHP will perform actions at the server level before rendering a page. This includes:
Loading dynamic content from a database
Posting information from a form to a database
Sending it to an email address like what you want to do
A lot of other stuff you'll learn if you stick with it.
To send an email when someone submits your form, the form needs to post to a PHP page.
Your form:
<form method="POST" action="sendmail.php">
<input type="text" name="name" />
<!-- Other inputs go here, etc. -->
<input type="submit" value="submit">
</form>
PHP to send the form (In sendmail.php)
<?php
$email = $_POST['inputName1'];
$name = $_POST['inputName2'];
$message = $_POST['inputName3'];
$phone = $_POST['inputName4'];
$yourEmail = "youremail#domain.com";
$to = $yourEmail;
$subject = "My Contact Form";
$message = $message;
$from = $email;
$headers = "From:" . $name;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
Here is a tutorial I found via Google: http://www.daniweb.com/web-development/php/threads/38784/php-sendmail-tutorial
There are probably better ones, but that should get you started.
Long story short, you need to learn PHP, and javascript.
Your other requirement (The poll) can be done many different ways, just google "Set up an online poll" for different ways. You can probably use jQuery/javascript and JSON, or XML, etc to power the polls as well as php. This tutorial may help you with that: http://net.tutsplus.com/tutorials/javascript-ajax/creating-a-dynamic-poll-with-jquery-and-php/
Good luck.
PHP is processed at the server level and the results are sent to the client's computer for display. JavaScript does its processing on the client's computer.
You can use the PHP Mail function to have the data entered in the form by the user sent to your email. Here is a link on how to use that: http://www.w3schools.com/php/php_mail.asp

How do I take an email address entered in a form, and autofill it in another form on a different page?

Ok, I have searched this site and I can't seem to find what I'm looking for. I am completely new to any kind of programming, so be patient please. :)
I have a website, at the bottom will be a "enter your email address to sign up for our newsletters" form. It will only have the one field, and a "submit" button. This submit button will take you to another page and I need the page to have auto-filled in the email address in the email address area, and then the person can choose the rest of their preferences.
Can someone please explain to me how to do this or point me to another post or site or something. Perhaps my search criteria is incorrect. Any help would be very much appreciated. Thanks.
UPDATE: Thank you everyone for your super fast and helpful answers!! I have, with your help, successfully resolved my question. I did some research on what was suggested (like I said, I'm a complete beginner...) and I came across this website, giving detailed instructions! -> Pre-Fill and Multi-Page Forms with JavaScript
Transferring information between two pages on a web application is a common problem. Since you've tagged this as Javascript, you might want to consider targeting your second page, let's call it pagetwo.html, with the HTTP 'GET' method.
<form id="firstPageEmailForm" action="pagetwo.html" method="get">
<input type="text" name="emailaddress" />
<input type="submit" />
</form>
On submit, the information will be passed to pagetwo.html like this: pagetwo.html?emailaddress=whatever#gmail.com
You can get at this information using the javascript object window.location.href. Just parse out the emailaddress field and set the value attribute of the input field in the new form on pagetwo.html.
you should put the email field in a input element and use the action of the FORM to point to another page - where you can request : request.form[....
As you only specifically mention javascript, I assume you're trying to do this client side. In which case, you just need to set a cookie, and then retrieve it to populate the field on the subsequent forms.
As you're using jquery, see the Cookie plugin.

Sending mails in Java script?

I am trying to write a function to send an email when the user clicks on "submit".
Any ideas how to do so?
Lets say I have a
<script>
function mail()
{
var players = document.getElementById('players').value;
var slots = document.getElementById('slots').value;
}
</script>
and I want to generate an mail with those three vars.
Thanks all :)!
You can't send emails from (client-side) JavaScript alone. What you can do is write a server-side program that takes inputs (maybe as a POST or XHR request), creates an email out of it and sends it.
You may need to post the details to a server which would mail or you can use the mailto function to invoke default mail client on the client's computer like
<form action="mailto:sample#stackoverflow.com" method="post" enctype="text/plain" >
variable1:<input type="text" name="v1">
variable2:<input type="text" name="v2">
<input type="submit" name="submit" value="Submit">
</form>
You will have to use it in combination of a server side language and javascript. You can use javascript to write the "interface" to the mail function. But you will need to look into php or another language.
A php example of this is
You can find more details on the manual here http://us.php.net/manual/en/book.mail.php
pinehead.tv fighting for smarter newbies
"You may need to post the details to a server which would mail or you can use the mailto function to invoke default mail client on the client's computer like
variable1:
variable2:
"
This answer above will not work for people who do not have a mail client installed on their os. the mailto feature in html will open up the users "outlook" type program to send the mail.

Sending mail from javascript

I am developing a static website where in i want to send an email when HTML "Send Button" is clicked. IF it is possible it would be nice if u can share the code
Thanks
short answer: No!
Long answer:
No, you can't send emails from static pages even using javascript. What you can do is to use ajax to send email from your html form.
It is possible ;-)
<input type="submit" value="Send" onclick="window.location ='mailto:email#address.com' "/>
In short: Forget it.
If you want to send email with the slightest resemblance of reliability, use a server side process. If you want to use JavaScript then you can use Ajax to pass the data to that server side process and/or SSJS.
It is not possible to send email from Javascript, you'll need to write a page in a language like PHP to receive the POST data and use the mail() command there.
I'm sorry but just with a static website you can't do it. One imaginable possibility would be make a very complex javascript code to access one webmail account you have, login there and send the email using this account to you. It's theoretically possible, but I've never seen something like it...

Categories