|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
Newbie Question
Hi, Im new to this forum, and to the art of creating websites! I have taught myself entirely from online tutorials!
I have my site designed, but I am having 2 issues. Let me say, incase it makes a difference, I designed the site in photoshop, I have sliced and optimised and imported it into dreamweaver. I have everything set up, except for the following 2 things..... 1, I have created a form, well, a few actually, and I dont know how to set it up so that I receive an email with all the ifo that the site visitor has imputted! 2. I dont know how to create a simple text box that is NOT editable by the visitors to the site. I want to create a text box that I can add to over time, thus retaining the history of the blogs, that is always the same size, but will become a scrolling box as and when needed. Does that make sense?? I hope so! Thanks! Joe |
|
#2
|
||||
|
||||
|
First off, welcome to the forums
For your form question, you should lay out forms like this; Code:
<form action="mailto:yourmail@email.com" method="post"> Your Name:<br /> <input name="name" value="Enter Name Here.." type="text" size="30" maxlength="60" /><br /><br /> Message:<br /> <input name="message" value="Enter Message Here.." type="text" size="30" maxlength="100" /><br /><br /> <input value="Submit" type="submit" /> <input value="Reset" type="reset" /> </form> Here, I'll break down the code for you to better understand: - The "action" attribute will tell your browser where the information in the form will go, so we use mailto.. which is an attribute which will hold the receiving address, - The method is "post", because we want to send the information to the aforementioned email address. At the very end of the form, you'll see "input" attributes, which hold the submit and reset buttons to send the form. Without these, you can enter all the info in the world, but wouldn't be able to post it. For your second question, just use a regular text area, but use the "readonly" attribute, to disable user input, like this; Code:
<textarea readonly="readonly" rows="10" cols="100"> Stuff goes in here.. </textarea> Hope this helps |
|
#3
|
|||
|
|||
|
Your a star!! Thank you so much in advance! I will try this later, Im off to my dads for the evening!
I will try it upon my return and let you know if Im successful at folowing your instructions! hehe! Again, thanks! Joe Quote:
|
|
#4
|
|||
|
|||
|
Hey, thanks for the tips! the imputting text one worked a treat! Unfortunately the mail form one didnt. I tried to imput the text you wrote down, but when I upload the page, it tries to send the form using outlook.
I want to make the form as easy as possible for visitors, I want them to be able to click "submit" and it automatically goes to my mailbox, without them having to have outlook setup. Is this possible?? Again, Thanks! Joe |
|
#5
|
||||
|
||||
|
Yes, it's possible, but with PHP, not HTML alone. I'll explain it for you here, so you can choose which you prefer (please note that your server will need PHP enabled to be able to use this).
First off, we start with our standard HTML form in our HTML page; Code:
<form method="post" action="send.php">
Your Email:<br />
<input type="text" maxlength="60" size="30" value="Enter Email Here.." name="email" /><br />
<br />
Message:<br />
<textarea cols="30" rows="10" name="message"></textarea><br />
<br />
<input type="submit" value="Submit" /> <input type="reset" value="Reset" />
</form>
The code breakdown is essentially the same as before (I've added a textarea tag instead of input, basically so the message area is bigger), only now you'll notice our action refers to a PHP file called send.php.. which is what we'll create now. So, create a new notepad document and save it in your directory as send.php. The PHP file will handle our posting function and it's very simple code; Code:
<?php $email = $_POST['email'] ; $message = $_POST['message'] ; mail( "email@email.com", "Subject", $message, "From: $email" ); print "Your email has been sent."; ?> The only code here that you need to alter here, would be the email@email.com, change this to the email address you wish to receive the mail at, upload both files to your server and you should be able to receive mail from the browser. Hope this helps Last edited by Squibbit : May 20th, 2008 at 08:21 AM. Reason: Coding error.. |
|
#6
|
|||
|
|||
|
Squibbit, thats ACE! Thanks so much! It works!
I have one final question on this subject, I have a couple of forms on my site for different reasons, A mailing list form, A general contact form and An Audition Application form. I know I cannot use the same send.php code for each, 1, as they all contain different info, and 2, cos that would be too easy! lol! Is there an easy way to write and name different .php codes to cover the forms? I tried altering the fields within the code and naming them send.php, and send2.php and send3.php, but that didnt work! loL! Cheers again!! |
|
#7
|
||||
|
||||
|
I've never tried it with multiple pages, so I don't know if using if and else statements would work for this in PHP (thinking out loud, sorry =P) so, for what will definitely work, is this;
For your mailing list, HTML; Code:
<form method="post" action="mail.php">
Your Email:<br />
<input type="text" maxlength="60" size="30" value="Enter Email Here.." name="recipient" /><br />
<br />
<input type="submit" value="Submit" /> <input type="reset" value="Reset" />
</form>
PHP (create a file mail.php); Code:
<? $recipient = $_GET['recipient'] ; mail( "email@email.com", "From: $recipient" ); print "Your mailing list submission has been sent."; ?> For your application form, HTML; Code:
<form method="post" action="apply.php">
Your Email:<br />
<input type="text" maxlength="60" size="30" value="Enter Email Here.." name="applicant" /><br />
<br />
Application Message:<br />
<textarea cols="30" rows="10" name="application"></textarea><br />
<br />
<input type="submit" value="Submit" /> <input type="reset" value="Reset" />
</form>
PHP (create a file called apply.php); Code:
<?php $applicant = $_POST['applicant'] ; $application = $_POST['application'] ; mail( "email@email.com", "Subject", $application, "From: $applicant" ); print "Your application has been sent."; ?> Hopefully you can see the differences between these codes to see what you need to create for more forms. |
![]() |
| Viewing: Tutorialized Forums > Web Design & Development > Dreamweaver > Newbie Question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|