473,606 Members | 3,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with a Form...

Chrisjc
375 Contributor
I am currently working on a form I need a few things from this form. First of all here is the link to what I have so far... ( http://www.triplesource.net/php/Decal%20Offer.html ) And posted below is the code for ( submit.php ) Now the first part of the form is just a HTML page with an action pointing to ( SUBMIT.php )

Now a problem I am having is one the e-mailing... the whole form to me... but also befor that I think I should say I have * as in indicator to the user that those fields must be filled in... how ever my code doesnt not stop them with an error message because I am not sure how to set up the right ( IF statment.)

Another issue on this form is I do not nor have I ever had someone upload a photo... I put the (BROWSE) box in place.. but I need to make it so they can only pick a GIF,JPG,TIF,PDF ,PSD, and so on any image format... that is one issue... 2nd with that is that I want the image to be displayed on the (submit.php) page and show them also once they have hit submit I am wanting the form infomation to be sent to my e-mail adress with the picture as well.. would you please be able to help me with this.???

I am very new to php/MySQL I also have another very big question but I will save it for another threed another project.... That I am trying to pull off... Thank you!

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <title>Free Windshield Decal Offer</title>
  5. <script language="JavaScript">
  6. <!--
  7. function FP_preloadImgs() {//v1.0
  8.  var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
  9.  for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
  10. }
  11.  
  12. function FP_swapImg() {//v1.0
  13.  var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
  14.  n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
  15.  elm.$src=elm.src; elm.src=args[n+1]; } }
  16. }
  17.  
  18. function FP_getObjectByID(id,o) {//v1.0
  19.  var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
  20.  else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
  21.  if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
  22.  for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
  23.  f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
  24.  for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
  25.  return null;
  26. }
  27. // -->
  28. </script>
  29. </head>
  30.  
  31. <body onload="FP_preloadImgs(/*url*/'Images/button14.gif',/*url*/'Images/button15.gif')">
  32. <?php
  33. $headers  = "From: MySite@mycom.com";
  34. $to       = "you@yoursite.com";
  35. $subj     = "Here is your html";
  36. $body     = "This form needs to be sent to my e-mail!!!";
  37. if (!mail($to, $subj, $body, $headers))
  38.   echo 'Error';
  39. else
  40.   echo 'Message sent';
  41. ?>
  42.  
  43. <div align="center">
  44.     <table border="0" id="table1">
  45.         <tr>
  46.             <td width="727" colspan="2">
  47.             <p align="center"><b><font size="2" face="Tahoma">Thank you, Your 
  48.             Application will be processed in 24 to 48 hours.</font></b><hr size="1" color="#C0C0C0"></td>
  49.         </tr>
  50.         <tr>
  51.             <td width="727" colspan="2" align="center"><b>
  52.             <font face="Tahoma" size="2">You submitted the following 
  53.             information:</font></b></td>
  54.         </tr>
  55.         <tr>
  56.             <td width="367" height="21" align="center">
  57.             <p align="right"><b><font face="Tahoma" size="2">
  58.             Select Vehicle Type:</font></b></td>
  59.             <td align="left">
  60.             <p align="left">&nbsp[PHP];<?php echo htmlspecialchars($_POST['Select']); ?></td>
  61.         </tr>
  62.         <tr>
  63.             <td width="367" align="center">
  64.             <p align="right"><b><font face="Tahoma" size="2">Street:</font></b></td>
  65.             <td align="left">
  66.             <p align="left">&nbsp[PHP];<?php echo ($_POST['Mailing']); ?></td>
  67.         </tr>
  68.         <tr>
  69.             <td width="367" align="center">
  70.             <p align="right"><b><font size="2" face="Tahoma">City:</font></b></td>
  71.             <td width="360" align="left">
  72.             &nbsp;&nbsp[PHP];<?php echo ($_POST['City']); ?></td>        </tr>
  73.         <tr>
  74.             <td width="367" align="center">
  75.             <p align="right"><b><font size="2" face="Tahoma">State:</font></b></td>
  76.             <td width="360" align="left">
  77.             &nbsp;&nbsp;[PHP]<?php echo ($_POST['State']); ?></td>        </tr>
  78.         <tr>
  79.             <td width="367" align="center">
  80.             <p align="right"><b><font size="2" face="Tahoma">Zip/Postal Code:</font></b></td>
  81.             <td width="360" align="left">
  82.             &nbsp;&nbsp[PHP];<?php echo ($_POST['Zip']); ?></td>    </tr>
  83.         <tr>
  84.             <td width="367" align="center">
  85.             <p align="right"><b><font face="Tahoma" size="2">
  86.             E-Mail Address:</font></b></td>
  87.             <td width="360" align="left">
  88.             <p align="left">
  89.             &nbsp[PHP];<?php echo ($_POST['E-mail']); ?> </td>    </tr>
  90.         <tr>
  91.             <td width="367" align="center">
  92.             <p align="right"><b><font face="Tahoma" size="2">
  93.             Copy of your aFe 
  94.             purchase invoice:</font></b></td>
  95.             <td align="left">
  96.             <p align="left">&nbsp;<?php echo ($_POST['FileToUpload']); ?></td>
  97.         </tr>
  98.         <tr>
  99.             <td width="367" valign="top" align="center">
  100.             <p align="right"><b><font face="Tahoma" size="2">Testimonial:</font></b></td>
  101.             <td width="360" align="left">
  102.             <p align="left">&nbsp;<?[PHP]php echo ($_POST['Testimonial']); ?><p align="left">&nbsp;<p align="left">&nbsp;<p align="left">&nbsp;</td>
  103.         </tr>
  104.         <tr>
  105.             <td width="367" valign="top" align="center">
  106.             <p align="right"><b><font face="Tahoma" size="2">Questions/Comments:</font></b></td>
  107.             <td width="360" align="left">
  108.             <p align="left">
  109.             &nbsp[PHP];<?php echo ($_POST['Questions']); ?><p align="left">            &nbsp;<p align="left">
  110.             &nbsp;<p align="left">
  111.             &nbsp;</td>
  112.         </tr>
  113.         <tr>
  114.             <td width="727" colspan="2" align="center">
  115.             <hr size="1" color="#C0C0C0"></td>
  116.         </tr>
  117.         <tr>
  118.             <td colspan="2">
  119.             <p align="center"><a href="http://afefilters.com/">
  120.             <img border="0" id="img1" src="Images/button13.gif" height="20" width="100" alt="Home page" onmouseover="FP_swapImg(1,0,/*id*/'img1',/*url*/'Images/button14.gif')" onmouseout="FP_swapImg(0,0,/*id*/'img1',/*url*/'Images/button13.gif')" onmousedown="FP_swapImg(1,0,/*id*/'img1',/*url*/'Images/button15.gif')" onmouseup="FP_swapImg(0,0,/*id*/'img1',/*url*/'Images/button14.gif')" fp-style="fp-btn: Simple Line 1; fp-font-style: Bold; fp-transparent: 1" fp-title="Home page"></a></p>
  121.         </tr>    </table>
  122. </div>
  123.  
  124. </body>
  125.  
  126. </html>
  127.  
Nov 9 '06 #1
1 1763
ronverdonk
4,258 Recognized Expert Specialist
Since I cannot see, in your code shown, where the <form> statement begins and ends, I visited the link you gave. There the <form> can be seen. Now this is going to be a long reply:

If you want to verify and cleanse all fields the user typed in, the easiest way to handle that is to start your script with a check whether the routine was called for the first time or due to a form submit. You can determine that by e.g. having a hidden field in your form such as with name 'submitted' and check the existence of that field in the $_POST array. If it is not present, the form was not submitted i.e. this is the first time your script was called. When field 'submitted' is in the $_POST array, it means that the form was submitted and you have to check the filled in fields.

So first you make it possible to determine if a form was submitted or not, by inserting the following hidden field statement right after the <form action=....> statement.
Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" name="submitted" value="1" />
Then you check, at the start of your script, if the script was called the first time or as a result of a submit. At the start of your script you insert the following:
[php]
<?php
// check if form was submitted
if (isset($_POST['submitted'])) {
$errors=array() ;
// it was submitted so here you do your field checking
// let's do E-mail as an example
// verify (a) filled in, (b) that is is an email address
if (!isset($_POST['E-mailmai']) OR
!ereg ('(^[0-9a-zA-Z_\.-]{1,}@([0-9a-zA-Z_\-]{1,}\.)+[0-9a-zA-Z_\-]{2,}$)', $_POST['email']) )
// email address incorrect, add msg to error array
$errors[] = "Invalid email address";
else
// email address okay, cleanse and save it
$email = stip_tags(trim( $_POST['E-mail']));
//
// more checking and validation ....
//
// .......

// at the end of your checking, see if any errors are set
if ($errors)
// if so, display the $errors array
// do not exit so the form is re-displayed
}
else {
// there are no errrors, send the email and exit
//
// here is your email build and send code
//
exit;
}
} // End of submit check

// from here on the form is displayed (again)
<html>
etc......
[/php]
Still to be coded: the display of all previously filled in fields in the case where the form is re-displayed. You don't want your users to fill in every field again in case of an error.

Let's, again, take the email <input> field as an example. The statement that requests the input must be changed, so it displays the content of variable $email (the var in which the email addess was saved). Like this
Expand|Select|Wrap|Line Numbers
  1. <input name="E-mail" size="36" style="float: left" value="<? echo $email ?>"></td>
  2.  
Good luck with your form.

Ronald :cool:
Nov 9 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1830
by: GrelEns | last post by:
hello, i had a trouble with re that i didn't understand (this is a silly example to show, to parse html i use sgmllib) : having this string : >>> s = """<form name="test" method="post" action="test.php"> <input type="text" name="title" size="1." value="test..."> <br> <a href="help.php">help</a>
6
1781
by: James Walker | last post by:
Can some one help I get an error of 'checkIndate' is null or not an object can someone please help. I can't work out why Thanks in advance James <form> <td height="24" colspan="7" valign="top"><form name="booknow"><select
5
2982
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig <<<<<<<<<<<<<<CODE>>>>>>>>>>>>>>>> <html>
0
1971
by: Pat Patterson | last post by:
I'm having serious issues with a page I'm developing. I just need some simple help, and was hoping someone might be able to help me out in here. I have a form, that consists of 3 pages of fields. I'd like to create a page in which all of this is stored as you move along as hidden variables, until the end, when the user submits. I can't figure out one thing: I have dynamic form elements (dropdowns), that I'd like to use instead of...
2
3293
by: chanchito_cojones | last post by:
hi there, I am needing some help with a database I am putting together. The database works off of a main Form, which then has buttons on it that will open up other forms. The problem I am having is that if I am updating any information on the current record, and then open one of the other forms, the new form will not show the updated information. I realize that a simple macro solves this problem by basically closing the first form,...
5
2193
by: Steve Patrick | last post by:
Hi All You guys are my last hope, despite spending money on books and hours reading them I still can not achieve the results I need. I have designed a database in Access 2000 based on 1 table, all has gone very well with one exception. The table is based on applications made by potential customers looking to buy franchise rights to particular locations and as part of the process they are asked to list their preferred locations 1 to 4....
5
2606
by: TD | last post by:
Hey All, I am hooking up our custom html (.chm) help file to our Access xp application, and, despite reading several posts and manuals on this, I still have a gap in my understanding... OK, so I've setup the registry keys to have a profile and I specify an AppHelpFile and TitleBar in that profile. This works swell: when I startup my application in runtime with the /profile option and then I press F1 on a form, our help file appears....
1
1961
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following statement. Help.ShowHelp(Parent:=Me, url:=Me.HELP_URL_PRE & Me.myWorker.HelpFile) How do I get it to go away when the program exits? Now when I quit the program that I called it form the help file is sill displayed. Is there a way to get a handle...
4
1467
by: jerry.ranch | last post by:
Say, on a data entry form a "HELP" cmbBUTTON that bounces the user off to word file that has help, or is there some other way to do it (like a label object with help on another form) Thanks Jerry
10
2525
by: 60325 | last post by:
This is the page where I collect the data in drop-down boxes with values of 1-10 and send it to a submitted page to do calculations. Example: Employee1 TeamScore(1-10) Employee2 TeamScore(1-10) Employee3 TeamScore(1-10) Employee4 TeamScore(1-10) Then I submit this page with all the values in TeamScore for every employee and I want to perform a calculation based on the values in the drop-down and a
0
8036
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8461
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8448
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6796
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5470
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3948
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4010
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1572
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1313
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.