Jump to content

PHP and Forms


Freedom1

Recommended Posts

How about making a video showing an example of using php with a contact form that is already in a website template? I won't be creating many forms from scratch, since I plan to use ready made website templates, but I'm having trouble deciphering just how to incorporate php into an existing form to make it work. One example would be helpful. Thanks.

Link to comment
Share on other sites

There are two videos here:-

http://www.killersites.com/university/

under Beginners PHP - Processing Forms with PHP

 

You don't have to edit the html form at all except to change the action to a php url to process the form, like

<form method="post" action="sendmail.php">

The form input tags should already have name="...".

All you need to add is the separate php processing file.

 

You may have to give the html file with the form a .php extension, but only if there is php processing to do on the page, which may not be the case. The form itself doesn't need php processing on the page unless the php in the action is to php code on the same page. If the processing is to a separate php file then the form page can still have a .html extension.

 

See also http://www.wickham43.net/formemail.php (which is just the basics. You probably need extra security code), or use a script from

http://www.jemjabella.co.uk/php-scripts-php-mail-form

http://www.formmail.com/

http://www.email-form.com/

Link to comment
Share on other sites

There are two videos here:-

http://www.killersites.com/university/

under Beginners PHP - Processing Forms with PHP

 

You don't have to edit the html form at all except to change the action to a php url to process the form, like

<form method="post" action="sendmail.php">

The form input tags should already have name="...".

All you need to add is the separate php processing file.

 

You may have to give the html file with the form a .php extension, but only if there is php processing to do on the page, which may not be the case. The form itself doesn't need php processing on the page unless the php in the action is to php code on the same page. If the processing is to a separate php file then the form page can still have a .html extension.

 

See also http://www.wickham43.net/formemail.php (which is just the basics. You probably need extra security code), or use a script from

http://www.jemjabella.co.uk/php-scripts-php-mail-form

http://www.formmail.com/

http://www.email-form.com/

Link to comment
Share on other sites

Thought I'd also mention in case it's useful -- I did a 6 part series on form validation with PHP and Javascript. It covers how to create a PHP/Javascript validated contact form, and hopefully should be easy for beginners to follow.

 

It's available in the KS University (http://www.killersites.com/university/) under PHP > Form Validation with PHP & Javascript.

 

Also, if you're having coding issues, feel free to post if you have trouble solving issues on your own. Sometimes a fresh set of eyes really helps.

Link to comment
Share on other sites

How are you trying to process the PHP?

You can't process PHP on your computer from a local php file unless you have a server (WampServer 2 or XAMPP) on your PC which incorporates Apache. You then put all the files into a special folder which the local server operates (C:\wamp\www folder for WampServer).

 

If you have uploaded your php file to your host and it still doesn't work online, does your hosting service support PHP?

Link to comment
Share on other sites

How are you trying to process the PHP?

You can't process PHP on your computer from a local php file unless you have a server (WampServer 2 or XAMPP) on your PC which incorporates Apache. You then put all the files into a special folder which the local server operates (C:\wamp\www folder for WampServer).

 

If you have uploaded your php file to your host and it still doesn't work online, does your hosting service support PHP?

Link to comment
Share on other sites

There are two videos here:-

http://www.killersites.com/university/

under Beginners PHP - Processing Forms with PHP

 

You don't have to edit the html form at all except to change the action to a php url to process the form, like

<form method="post" action="sendmail.php">

The form input tags should already have name="...".

All you need to add is the separate php processing file.

 

You may have to give the html file with the form a .php extension, but only if there is php processing to do on the page, which may not be the case. The form itself doesn't need php processing on the page unless the php in the action is to php code on the same page. If the processing is to a separate php file then the form page can still have a .html extension.

 

See also http://www.wickham43.net/formemail.php (which is just the basics. You probably need extra security code), or use a script from

http://www.jemjabella.co.uk/php-scripts-php-mail-form

http://www.formmail.com/

http://www.email-form.com/

Link to comment
Share on other sites

I fear I may have led you down the garden path. The form is actually Javascript. Here is the html. There is no "action" tag. Is this form poorly coded then, or more sophisticated than the usual?

 

<div class="container1">

<div class="col-5">

<div class="h3"><input type="text" onblur="if(this.value=='') this.value='Name:'" onfocus="if(this.value =='Name:' ) this.value=''" value="Name" /></div>

<div class="h3"><input type="text" onblur="if(this.value=='') this.value='E-mail:'" onfocus="if(this.value =='E-mail:' ) this.value=''" value="Email" /></div>

<div class="h3"><input type="text" onblur="if(this.value=='') this.value='Phn:'" onfocus="if(this.value =='FAX:' ) this.value=''" value="Phn" /></div>

</div>

<div class="col-6">

<textarea rows="40" cols="30" onblur="if(this.value=='') this.value='Message:'" onfocus="if(this.value =='Message:' ) this.value=''" >Message</textarea>

 

</div>

<br class="clear" />

</div>

</div>

</div>

<br class="clear" />

</div>

</div>

</div>

</div>

</div>

<div class="left-bottom-corner png">

<div class="right-bottom-corner png">

<div class="border-bottom png"><div class="pa indent4"></div><div class="container"><a href="#" class="link-2" onclick="document.getElementById('form').submit()"><em><b>Submit</b></em></a></div></div>

</div>

</div>

</div>

</div>

</form>

</div>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...