PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old June 25th, 2002, 10:05 PM
lovepoet lovepoet is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 lovepoet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Looking for sample code

Hi,
I'm just getting started on PHP
and I would like to read some sample code for form input + validation (javascript?), with email & db insertion on form submit.

Thanks

Reply With Quote
  #2  
Old June 26th, 2002, 10:41 PM
eplummer eplummer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Saratoga Springs, NY, US
Posts: 15 eplummer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 sec
Reputation Power: 0
Send a message via ICQ to eplummer Send a message via Yahoo to eplummer
RE: Looking for sample code

Hello Lovepoet,

I think I can help you with the JavaScript. I still have to learn the PHP for forms yet.

<!--start JavaScript-->
<SCRIPT>
<!--
function validateform()
{
if(document.onlineform.first_name.value=="") {
window.alert ("Please Enter Your First Name!");
document.onlineform.first_name.focus();
return false;
}
if(document.onlineform.middle_name.value=="") {
window.alert ("Please Enter Your Middle Name!");
document.onlineform.middle_name.focus();
return false;
}
if(document.onlineform.last_name.value=="") {
window.alert ("Please Enter your Last Name!");
document.onlineform.last_name.focus();
return false;
}
if (document.onlineform.street_address1.value=="") {
window.alert ("Please Enter your Street Address!");
document.onlineform.street_address1.focus();
return false;
}
if (document.onlineform.City.value=="") {
window.alert ("You have not entered your City!");
document.onlineform.City.focus();
return false;
}
if (document.onlineform.State.value=="") {
window.alert ("Please Enter your State or Region!");
document.onlineform.State.focus();
return false;
}
if (document.onlineform.Country.value=="") {
window.alert ("Please Specify what country you are from!");
document.onlineform.Country.focus();
return false;
}
}
//-->
</SCRIPT>
<!--end JavaScript-->

Ed
Saratoga Springs, NY

Reply With Quote
  #3  
Old June 27th, 2002, 02:00 AM
Taoism Taoism is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Winnipeg, MB, Canada
Posts: 81 Taoism User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 sec
Reputation Power: 2
RE: Looking for sample code

Lemme try this off the top of my head...

php Code:
Original - php Code
  1.  
  2. <?php
  3. if(isset($_POST['submit'])){
  4. //backend validation in case user has javascript disabled
  5. $errmsg='';
  6. if($_POST['name']==''){$errmsg='Please enter a name.';}
  7. if($_POST['email']==''){$errmsg='Please enter an email address.';}
  8. if($errmsg!=''){
  9. echo '<h3>The following errors were found.  Press the back button and correct them.</h3>';
  10. echo $errmsg;
  11. }else{
  12. echo 'Your data was successfully validated.';
  13. }
  14. }else{
  15. ?>
  16. <form method="POST" action="test.php">
  17. Name:<input type="textbox" name="name"><br/>
  18. Email:<input type="textbox" name="email"><br/>
  19. <input type="submit" name="submit" value="submit">
  20. </form>
  21. <?php
  22. }
  23. ?>


I would normally make it more complex..like using a regexp to validate the email, etc... but I am in a hurry atm....

Cheers,
Keith.

Reply With Quote
  #4  
Old June 27th, 2002, 05:06 PM
lovepoet lovepoet is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 lovepoet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Looking for sample code

Guys!

I do believe that between your two replies and 'Core PHP' I can jig something together.

Many thanks!

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Looking for sample code


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway