473,385 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help with a Form...

Chrisjc
375 256MB
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 1746
ronverdonk
4,258 Expert 4TB
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
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"...
6
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"...
5
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 ...
0
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...
2
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...
5
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,...
5
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...
1
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...
4
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...
10
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 ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.