Jump to content

FORM problem


gisteam

Recommended Posts

Frankly, I don't know jack.  I have looked at some so-called tutorials and they lose me right away.

 

I have done html for years.  I am trying to make a form (which I used to be able to do).

 

I went to Emailmeform and designed a form close to what we need, then customized it some to look like I wanted.  It has problems and because they have the php code, there isnt much i can do about that.

 

I re-created the form using one I found in a tutorial and example to model my changes after, but it doesn't work.  I don't understand all the variable's syntax.  I know I should keep searching till I find a tutorial that I can swallow, but we really just need this form to work so I can move on to other projects.

 

In the form, we need all of the fields marked with a red asterisk to be required.  The checkbox items could be just one checkbox to be clicked if you want that done.  I tried to follow the example of the php to have it check each field as entered to determine if the input is acceptable, but it doesnt work.

 

Here is the php code called confirm.php:

 

<html>

<BODY BGCOLOR="#FFFFFF">

<%

if ((!$name ) && (!$org) && (!$dept) && (!$phone) &&

 

(!$email))  {

 

echo "One of the fields in the contact

 

information section is invalid or blank, please enter correct

 

information";

echo "<p>";

echo "Please use the 'Back' button to

 

continue.";

echo "</p>";

echo "<a href='/form.html'

 

onclick='self.history.back();'>Back</a>";

exit;

}

 

$message="Name: $name\n\n"."Organization:

 

$org\n\n"."Department: $dept\n\n"."Phone:

 

$phone\n\n"."Email: $email\n\n"."Project: &project"."Title:

 

$title"."Size: $size"."Qty: $qty"."CustomSize:

 

$custom"."DigitalCopy: checkbox".";

 

 

mail("[email protected]","$subject","$messa

 

ge","From:Form.$email\r\nReply-to:$email");

echo "<p>Thank you for requesting our services. Your

 

details have been forwarded and we will be in contact

 

within 2 working days.</p>";

echo "<p>From: $email</P>";

echo "<p>Subject: $subject</p>";

echo "<p>Message: $message</p>";

echo "<p>";

echo $text;

echo "</p><a href='/gis.html'><b>Return to the GIS

 

Page</b></a>";

%>

</BODY>

</HTML>

 

And here is the form called form1:

 

<html>

<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body>

<form action="/confirm.php" method="POST" >

<table cellpadding="2" cellspacing="0" border="0" bgcolor="#FFFFFF">

<tr><td><font face="Verdana" size="2" color="#000000"></font> <div style="" id="mainmsg">

  <input type="hidden" name="recipient">

  <input type="hidden" name="subject" value="Map Request Form">

  <input type="hidden" name="redirect" value="[email protected]">

 

</div></td></tr>

</table><br>

<table align="center" cellpadding="2" cellspacing="0" border="1" bgcolor="#FFFFFF" width=600 border="1" bordercolor="white">

<tr>

<td colspan=2 border="1" bordercolor="white"><center><br>

<b>CITY OF HATTIESBURG'S</b><BR><font size=5>GEOGRAPHIC INFORMATION SYSTEMS</font><BR>

<b>MAP REQUEST FORM</b><br> </td>

    </tr>

 

<tr bordercolor="black">

<td colspan=2 border="1" bordercolor="black"><center>

<b>GIS PROJECT PROCEDURES</b></center>

</td>

</tr>

 

<tr>

<td  colspan=2 border="1" bordercolor="white">

<p align="justify">Map requests must be submitted a minimum of one week prior to the date needed.<br><br>

Base maps include the following features: streets, city limits, wards, and water bodies. Any other features you would like shown on the map should be requested in this form.<br><br>

Please contact us for any custom sized maps or if your quantity exceeds more than 25 copies. <br><br>

The GIS team will compose a draft that will be presented for evaluation to determine if it will suit the needs of the request. If changes are to be made, please

allow us up to one full day to be able to make appropriate changes. We will then deliver your request in the required format.<br><br>

<b style='color:red'>*</b> indicates a required field</td>

</tr>

 

<tr>

<td colspan=2 border="1" bordercolor="black"><center>

<b>CONTACT INFORMATION</b></center>

</td>

</tr>

 

<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">NAME </font><b style='color:red'> *</b></td> <td><input type="text" name="name" size="30"> </td></tr>

<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">ORGANIZATION </font><b style='color:red'>*</b></td> <td><input type="text" name="org" size="30"> </td></tr>

<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">DEPARTMENT </font><b style='color:red'>*</b></td> <td><input type="text" name="dept" size="30"> </td></tr>

<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">PHONE </font><b style='color:red'>*</b></td> <td><input type="text" name="phone" size="12"> </td></tr>

<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">EMAIL ADDRESS </font><b style='color:red'>*</b></td> <td><input type="text" name="email" size="30"> </td></tr>

<tr>

<td colspan=2 border="1" bordercolor="black"><center>

<b>PROJECT INFORMATION</b></center>

</td>

</tr>

 

<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">PROJECT </font><b style='color:red'>*</b></td> <td><input type="text" name="project" size="30"> </td></tr>

<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">MAP TITLE </font><b style='color:red'>*</b></td> <td><input type="text" name="title" size="30"> </td></tr>

<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">MAP SIZE </font><b style='color:red'>*</b></td> <td><select name="size">

<option value="8x10"> LETTER (8" x 10") </option>

<option value="11x17"> TABLOID (11" x 17") </option>

<option value="18x24"> .POSTER (18" x 24") </option>

<option value="24x24"> .SQUARE POSTER (24" x 24") </option>

<option value="24x36"> .POSTER (24" x 36") </option>

<option value="36x36"> .SQUARE POSTER (36" x 36") </option>

<option value="36x48">  POSTER (36" x 48" )</option>

<option value="CUSTOM"> CUSTOM (ENTER SIZE BELOW)</option>

</select> </td></tr>

<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">QUANTITY </font><b style='color:red'>*</b></td> <td><input type="text" name="qty" size="3"> </td></tr>

<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">CUSTOM SIZE DIMENSIONS </font></td> <td><input type="text" name="custom " size="10"> </td></tr>

<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">DIGITAL COPY? </font></td>

<td><input type=checkbox name="digi" value="YES" id="check100"><font face="Verdana" size="2" color="#000000"><label for="check100">YES</label></font>

<br> </td></tr>

<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">PRINTED COPY? </font></td>

<td><input type=checkbox name="printed" value="YES" id="check110"><font face="Verdana" size="2" color="#000000"><label for="check110">YES</label></font>

<br> </td></tr>

<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">MOUNTED? </font></td>

  <td><input type=checkbox name="mount" value="YES" id="check120"><font face="Verdana" size="2" color="#000000"><label for="check120">YES</label></font>

<br> </td></tr>

 

  <tr valign="top"> <td><font face="Verdana" size="2" color="#000000">COMMENTS </font></td> <td><textarea name="comments" cols="60" rows="10"></textarea><br> </td></tr>

  <tr valign="top"> <td><font face="Verdana" size="2" color="#000000">REQUEST DATE </font></td> <td><input type="text" name="request" size="12"><b style='color:red'>*</b> </td></tr>

  <tr valign="top"> <td><font face="Verdana" size="2" color="#000000">DEADLINE DATE </font></td> <td><input type="text" name="deadline" size="12"> <b style='color:red'>*</b></td></tr>

  <tr> <td colspan="2"></td></tr><tr> <td> </td>

  <td align="right"><input type="submit" class="btn" value="SEND FORM" name="Submit">

      <input type="reset" class="btn" value="  RESET  " name="Clear"></td></tr>

  <tr><td colspan=2 align="center"><br></td></tr>

  </table>

<div align="center">

    <div align="right">

      <div align="left">

        <pre class="FormCSS">  </pre>

        <c></c></div>

</form>

 

</body</html>

 

I realize this is TOO MUCH to ask, but I dont know where to turn

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/
Share on other sites

Gee, tanks.  I got an error message back:

 

PHP Parse error: syntax error, unexpected T_IF in C:\Inetpub\wwwroot\www.hattiesburgms.com\statefedprograms\confirm.php on line 4

 

That line is:

 

if ((!$name ) && (!$org) && (!$dept) && (!$phone) && (!$email))  {

 

the beginning of the error checking loop.  is it the && or do I need commas separating or what?...

 

(Thanks for the quick response.  What do you mean by "And it's quite handy if you put all of your code as a code, because now you really can't see anything"  are you just saying that the echo command pops out errors?)

 

I will try to find some code that emulates this section, so I can compare and see if I can figure out what's wrong.  Thanks again.

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/#findComment-1016217
Share on other sites

No I mean that if you post a question, put your code between php brackets so the code gets colour and is easier to read, easier to check and see if there are thing wrong.

<?php
if ((!$name ) && (!$org) && (!$dept) && (!$phone) && 

(!$email))  {
   
   echo "One of the fields in the contact information section is invalid or blank, please enter correct information";
   echo "<p>";
   echo "Please use the 'Back' button to continue.";
   echo "</p>";
   echo "<a href='/form.html' onclick='self.history.back();'>Back</a>";
   exit;
} 

$message="Name: $name\n\n"."Organization: $org\n\n"."Department: $dept\n\n"."Phone: $phone\n\n"."Email: $email\n\n"."Project: &project"."Title: $title"."Size: $size"."Qty: $qty"."CustomSize: $custom"."DigitalCopy: checkbox".";

mail("[email protected]","$subject","$message","From:Form.$email\r\nReply-to:$email");
echo "<p>Thank you for requesting our services. Your details have been forwarded and we will be in contact within 2 working days.</p>";
echo "<p>From: $email</P>";
echo "<p>Subject: $subject</p>";
echo "<p>Message: $message</p>";
echo "<p>";
echo $text;
echo "</p><a href='/gis.html'><b>Return to the GIS 

Page</b></a>";
?>

 

Is a lot easier to read than a whole plain black text.

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/#findComment-1016256
Share on other sites

Also, instead of

if ((!$name ) && (!$org) && (!$dept) && (!$phone) && (!$email))  {echo'blabla';}

 

try:

if (!isset ($email) || !isset($org) || !isset($dept) || !isset($phone)){echo'blabla';}

 

|| means or.

! means if it's not

 

So if $email is not set, you get an error. OR if $org is not set, you also get an error. OR and so on and so forth. If you use and, none of the 5 things should be set in order to get the message.

 

edit: just tested my line and doesn't give an error, so that should do that.

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/#findComment-1016260
Share on other sites

And by code he means dont do this:

 

<?php echo 'omg'; ?>

 

do this

 

[code ]

 

<?php echo 'omg'; ?>

 

[/code ]

 

that way it is nicely formatted for us.

 

and obviously take the space out before the bracket closes in the top and bottom. If i did it'd show it as code not a code tag lolz

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/#findComment-1016262
Share on other sites

ok, let's see if i have it right now...

 


<html>
<BODY BGCOLOR="#FFFFFF">
<%
if ((!$name ) && (!$org) && (!$dept) && (!$phone) && 

(!$email))  {
   
   echo "One of the fields in the contact 

information section is invalid or blank, please enter correct 

information";
   echo "<p>";
   echo "Please use the 'Back' button to 

continue.";
   echo "</p>";
   echo "<a href='/form.html' 

onclick='self.history.back();'>Back</a>";
   exit;
} 

$message="Name: $name\n\n"."Organization: 

$org\n\n"."Department: $dept\n\n"."Phone: 

$phone\n\n"."Email: $email\n\n"."Project: &project"."Title: 

$title"."Size: $size"."Qty: $qty"."CustomSize: 

$custom"."DigitalCopy: checkbox".";


mail("[email protected]","$subject","$messa

ge","From:Form.$email\r\nReply-to:$email");
echo "<p>Thank you for requesting our services. Your 

details have been forwarded and we will be in contact 

within 2 working days.</p>";
echo "<p>From: $email</P>";
echo "<p>Subject: $subject</p>";
echo "<p>Message: $message</p>";
echo "<p>";
echo $text;
echo "</p><a href='/gis.html'><b>Return to the GIS 

Page</b></a>";
%>
</BODY>
</HTML>

 

And da form:

 


<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="/confirm.php" method="POST" >
<table cellpadding="2" cellspacing="0" border="0" bgcolor="#FFFFFF">
<tr><td><font face="Verdana" size="2" color="#000000"></font> <div style="" id="mainmsg"> 
  <input type="hidden" name="recipient">
  <input type="hidden" name="subject" value="Map Request Form">
  <input type="hidden" name="redirect" value="[email protected]">

</div></td></tr>
</table><br>
<table align="center" cellpadding="2" cellspacing="0" border="1" bgcolor="#FFFFFF" width=600 border="1" bordercolor="white">
<tr>
   <td colspan=2 border="1" bordercolor="white"><center><br>
   <b>CITY OF HATTIESBURG'S</b><BR><font size=5>GEOGRAPHIC INFORMATION SYSTEMS</font><BR>
   <b>MAP REQUEST FORM</b><br> </td>
    </tr>
   
   <tr bordercolor="black">
   <td colspan=2 border="1" bordercolor="black"><center>
      <b>GIS PROJECT PROCEDURES</b></center>
   </td>
   </tr>
   
   <tr>
   <td  colspan=2 border="1" bordercolor="white">
   <p align="justify">Map requests must be submitted a minimum of one week prior to the date needed.<br><br>
Base maps include the following features: streets, city limits, wards, and water bodies. Any other features you would like shown on the map should be requested in this form.<br><br>
Please contact us for any custom sized maps or if your quantity exceeds more than 25 copies. <br><br>
The GIS team will compose a draft that will be presented for evaluation to determine if it will suit the needs of the request. If changes are to be made, please 
allow us up to one full day to be able to make appropriate changes. We will then deliver your request in the required format.<br><br>
<b style='color:red'>*</b> indicates a required field</td>
   </tr>
   
   <tr>
   <td colspan=2 border="1" bordercolor="black"><center>
      <b>CONTACT INFORMATION</b></center>
   </td>
   </tr>

<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">NAME </font><b style='color:red'>   *</b></td> <td><input type="text" name="name" size="30"> </td></tr>
<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">ORGANIZATION </font><b style='color:red'>*</b></td> <td><input type="text" name="org" size="30"> </td></tr>
<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">DEPARTMENT </font><b style='color:red'>*</b></td> <td><input type="text" name="dept" size="30"> </td></tr>
<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">PHONE </font><b style='color:red'>*</b></td> <td><input type="text" name="phone" size="12"> </td></tr>
<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">EMAIL ADDRESS </font><b style='color:red'>*</b></td> <td><input type="text" name="email" size="30"> </td></tr>
<tr>
   <td colspan=2 border="1" bordercolor="black"><center>
      <b>PROJECT INFORMATION</b></center>
   </td>
   </tr>

<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">PROJECT </font><b style='color:red'>*</b></td> <td><input type="text" name="project" size="30"> </td></tr>
<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">MAP TITLE </font><b style='color:red'>*</b></td> <td><input type="text" name="title" size="30"> </td></tr>
<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">MAP SIZE </font><b style='color:red'>*</b></td> <td><select name="size">
<option value="8x10"> LETTER (8" x 10") </option>
<option value="11x17"> TABLOID (11" x 17") </option>
<option value="18x24"> .POSTER (18" x 24") </option>
<option value="24x24"> .SQUARE POSTER (24" x 24") </option>
<option value="24x36"> .POSTER (24" x 36") </option>
<option value="36x36"> .SQUARE POSTER (36" x 36") </option>
<option value="36x48">  POSTER (36" x 48" )</option>
<option value="CUSTOM"> CUSTOM (ENTER SIZE BELOW)</option>
</select> </td></tr>
<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">QUANTITY </font><b style='color:red'>*</b></td> <td><input type="text" name="qty" size="3"> </td></tr>
<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">CUSTOM SIZE DIMENSIONS </font></td> <td><input type="text" name="custom " size="10"> </td></tr>
<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">DIGITAL COPY? </font></td> 
<td><input type=checkbox name="digi" value="YES" id="check100"><font face="Verdana" size="2" color="#000000"><label for="check100">YES</label></font>
<br> </td></tr>
<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">PRINTED COPY? </font></td>
<td><input type=checkbox name="printed" value="YES" id="check110"><font face="Verdana" size="2" color="#000000"><label for="check110">YES</label></font>
<br> </td></tr>
<tr valign="top"> <td><font face="Verdana" size="2" color="#000000">MOUNTED? </font></td>
  <td><input type=checkbox name="mount" value="YES" id="check120"><font face="Verdana" size="2" color="#000000"><label for="check120">YES</label></font>
<br> </td></tr>
  
  <tr valign="top"> <td><font face="Verdana" size="2" color="#000000">COMMENTS </font></td> <td><textarea name="comments" cols="60" rows="10"></textarea><br> </td></tr>
  <tr valign="top"> <td><font face="Verdana" size="2" color="#000000">REQUEST DATE </font></td> <td><input type="text" name="request" size="12"><b style='color:red'>*</b> </td></tr>
  <tr valign="top"> <td><font face="Verdana" size="2" color="#000000">DEADLINE DATE </font></td> <td><input type="text" name="deadline" size="12"> <b style='color:red'>*</b></td></tr>
  <tr> <td colspan="2"></td></tr><tr> <td> </td>
   <td align="right"><input type="submit" class="btn" value="SEND FORM" name="Submit">
       <input type="reset" class="btn" value="  RESET  " name="Clear"></td></tr>
   <tr><td colspan=2 align="center"><br></td></tr>
   </table>
<div align="center">
    <div align="right">
      <div align="left">
        <pre class="FormCSS">  </pre>
        <c></c></div>
</form>

</body</html>

 

thanks for looking and instructing a babe in the woods!

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/#findComment-1016275
Share on other sites

try

 next time, gives color.

Some remarks:
1) Still have <% instead of <?php ... ?>

2) <a href='/form.html' onclick='self.history.back();'>Back</a>
Don't really see why it has 2 links.

3) exit; needs to be exit();

For the rest I don't see any mistakes right away, but I'm not really familiar with the mailing thingy. I'm new to PHP and stuff. And the form I can't check eather, I'm having problems with my own forms

Though I would check the action of the form; if confirm.php and the other file are in the same directory, it doesn't need to be /confirm.php but only confirm.php, though I don't know if this makes a difference.

The form seems very nice by the way!

Perhaps; to reciept the information given in the html form, don't you need to use $_POST['org'] in your php file? Think you do.
For example:
[code=php:0]$org = $_POST['org'];[/code]

 

Otherwise it doesn't know it has to retreive those details.

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/#findComment-1016286
Share on other sites

1. While it is not the best, asp tags ( <% %> ) are allowed, if your php.ini has asp_tags=1.

 

3. exit; is just fine.

 


<?php

//exit program normally
exit;
exit();
exit(0);

//exit with an error code
exit(1);
exit(0376); //octal

?>

 

source: http://www.php.net/manual/en/function.exit.php

 

Do you have errors enabled on your server?

 

If not, paste this at the top of your save code.

 

ini_set('display_errors', 1); 
error_reporting(E_ALL);

 

And tell us what it says.

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/#findComment-1016306
Share on other sites

<html>
<BODY BGCOLOR="#FFFFFF">
<php echo
if (!isset ($email) || !isset($org) || !isset($dept) || 

!isset($phone) || !isset($project) || !isset($title) || !isset($size) 

|| !isset($qty) || !isset($digi) || !isset($print) || !isset($mount) || 

!isset($request) || !isset($deadline))

echo "One of the fields  is invalid or blank, 

please enter correct information";
echo "<p>";
echo "Please use the 'Back' button to 

continue.";
echo "</p>";
echo "< onclick='self.history.back();'>";
exit();

} 

$message="Name: $name\n\n"."Organization: 

$org\n\n"."Department: $dept\n\n"."Phone: 

$phone\n\n"."Email: $email\n\n"."Project: &project"."
Title: $title"."Size: $size"."Qty: $qty"."CustomSize: 

$custom"."DigitalCopy: $digi"."Printed: 

$printed"."Mounted: $mount"."Comments: 

$comments"."RequestDate: $request"."DeadlineDate: 

$deadline".";
mail("[email protected]","$subject","$messa

ge","From:Form.$email\r\nReply-to:$email");


echo "<p>Thank you for requesting our services. Your 

details have been forwarded and we will be in contact 

within 2 working days.</p>";
echo "<p>From: $email</P>";
echo "<p>Subject: $subject</p>";
echo "<p>Message: $message</p>";
echo "<p>";
echo $text;
echo "</p><a href='/gis.html'><b>Return to the GIS 

Page</b></a>";
/php>
</BODY>
</HTML>

 

what does the ? do anyway?

 

Thanks a heap arbitter.  Why did you put a post command by the org value?  do you mean I have to put a post command by each value?  It was my inference that the code I copied and altered  gathered all the input values under $message and used the mail("pentrekin...  etc. to email it to me.  I could (easily) be wrong.  I am clueless where a post command would go in this php file.  in the html form page  it goes in the opening line of the form tag.

 

PS: sorry, I grabbed the old version of the file and posted it.  This is the latest one with changes mentioned here.  The Form page actually now doesn't have the / before the confirm.php.  I caught that a while ago.

 

wish this forum allowed me to just edit the original entry like some i have been on.

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/#findComment-1016313
Share on other sites

You must begin a php sequence with '<?php'

 

and end it with '?>'

 

Here you endid it with '/php>'

 

which isn't correct eather.

 

And yes, I do believe you have to do a $_POST['whatever'] for every variable. If you try it out as you have it right now, I don't expect that the variables are set, as the php file doesn't have any clue where the $org and allt he other things come from. The form's method is 'post' as you can see, so the selected thingys get posted, but you do still need to retrieve it.

 

take a look here: http://www.tizag.com/phpT/examples/formfinale.php

The form's

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/#findComment-1016332
Share on other sites

It's because you're echoing an if...

 


<php echo
if (!isset ($email) || !isset($org) || !isset($dept) || 

!isset($phone) || !isset($project) || !isset($title) || !isset($size) 

|| !isset($qty) || !isset($digi) || !isset($print) || !isset($mount) || 

!isset($request) || !isset($deadline))

echo "One of the fields  is invalid or blank, 

please enter correct information";
echo "<p>";
echo "Please use the 'Back' button to 

continue.";
echo "</p>";
echo "< onclick='self.history.back();'>";
exit();

} 

 

use something like this

 


<php <-- NO ECHO 

if (!isset ($email) || !isset($org) || !isset($dept) || !isset($phone) || !isset($project) || !isset($title) || !isset($size) || !isset($qty) || !isset($digi) || !isset($print) || !isset($mount) || !isset($request) || !isset($deadline)){

echo "One of the fields  is invalid or blank, please enter correct information";
echo "<p>";
echo "Please use the 'Back' button to continue.";
echo "</p>";
echo "<a href='#' onclick='self.history.back();'>Click Me</a>"; <- what is this?? you have to onclick it to like an <a> or an image...
exit();

} 

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/#findComment-1016333
Share on other sites

<?php 
$name = $_POST["name"];
$org = $_POST["org"];
$dept = $_POST["dept"];
$phone = $_POST["phone"];
$email = $_POST["email"];
$project = $_POST["project"];
$title = $_POST["title"];
$size = $_POST["size"];
$qty = $_POST["qty"];
$digi = $_POST["digi"];
$print = $_POST["print"];
$mount = $_POST["mount"];
$request = $_POST["request"];
$deadline = $_POST["deadline"];

if (!isset ($name) || !isset($org) || !isset($dept) || !isset($phone) || !isset($email) || !isset($project) || !isset($title) || !isset($size) || !isset($qty) || !isset($digi) || !isset($print) || !isset($mount) || !isset($request) || !isset($deadline))

echo "One of the fields  is invalid or blank, please enter correct information";
echo "<p>";
echo "Please use the 'Back' button to continue.";
echo "</p>";
echo "<a href='#' onclick='self.history.back();'>BACK </a>"; 	exit();


$message="Name: $name\n\n"."Organization: $org\n\n"."Department: $dept\n\n"."Phone: $phone\n\n"."Email: $email\n\n"."Project: &project"."
Title: $title"."Size: $size"."Qty: $qty"."CustomSize: $custom"."DigitalCopy: $digi"."Printed: $printed"."Mounted: $mount"."Comments: $comments"."RequestDate: $request"."DeadlineDate: $deadline".";

mail("[email protected]","$project","$message","From:Form1.$email\r\nReply-to:$email"); 

echo "<p>Thank you for requesting our services. Your details have been forwarded and we will be in contact within 2 working days.</p>";
echo "<p>From: $email</P>";
echo "<p>Subject: $subject</p>";
echo "<p>Message: $message</p>";
echo "<p>";
echo $text;
echo "</p><a href='/gis.html'><b>Return to the GIS Page</b></a>";
/?>

 

I get an error message now at the line beginning with: mail(

unexpected T_STRING

 

so something about my actual mail command line is rong.

 

thanks fo rall the help arbitter.  that link is what i have been looking for.  I'll try to look it over tomorrow.  It is off to home for me now.

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/#findComment-1016472
Share on other sites

Ok, I'm guessing that if your one of your required fields isn't set, you want to error out and exit. The way your if is structured, it will not do that.

 

you have just a single if line, no encapsulating { } 's. So, only the immediate line will be executed if the statement is true.

 

Observe:

 


$test=true;

// just an if

if($test)
     echo 'this works'; <- will get triggered because of the if, since $test==(bool) true;

     exit(); <- will always trigger, regardless of the if

// an if with more than one lines, encapsulated

if($test){

     echo 'this works';

     exit;

     }//end if

 

So firstly you need to properly mark your if, and i'm guessing else.

 


if (!isset ($name) || !isset($org) || !isset($dept) || !isset($phone) || !isset($email) || !isset($project) || !isset($title) || !isset($size) || !isset($qty) || !isset($digi) || !isset($print) || !isset($mount) || !isset($request) || !isset($deadline)){

echo "One of the fields  is invalid or blank, please enter correct information";
echo "<p>";
echo "Please use the 'Back' button to continue.";
echo "</p>";
echo "<a href='#' onclick='self.history.back();'>BACK </a>"; 	
        exit(); // <-- needs to be on its own line

}else{

$message="Name: $name\n\n"."Organization: $org\n\n"."Department: $dept\n\n"."Phone: $phone\n\n"."Email: $email\n\n"."Project: &project"."
Title: $title"."Size: $size"."Qty: $qty"."CustomSize: $custom"."DigitalCopy: $digi"."Printed: $printed"."Mounted: $mount"."Comments: $comments"."RequestDate: $request"."DeadlineDate: $deadline"; // <-- no extra "

mail("[email protected]","$project","$message","From:Form1.$email\r\nReply-to:$email"); 

echo "<p>Thank you for requesting our services. Your details have been forwarded and we will be in contact within 2 working days.</p>";
echo "<p>From: $email</P>";
echo "<p>Subject: $subject</p>";
echo "<p>Message: $message</p>";
echo "<p>";
echo $text;
echo "</p><a href='/gis.html'><b>Return to the GIS Page</b></a>";

}//end else

 

And your T_STRING error is probably the extra quote at the end, near '$deadline".";' ..

 


$message="Name: $name\n\n"."Organization: $org\n\n"."Department: $dept\n\n"."Phone: $phone\n\n"."Email: $email\n\n"."Project: &project"."
Title: $title"."Size: $size"."Qty: $qty"."CustomSize: $custom"."DigitalCopy: $digi"."Printed: $printed"."Mounted: $mount"."Comments: $comments"."RequestDate: $request"."DeadlineDate: $deadline"; // <-- no extra quote

 

EDIT: And really, you don't need to concatenate " ed strings, since the variables inside are interpreted.

 

This is much nicer and way easier to read.

 


$message="Name: $name\n\n
          Organization: $org\n\n
          Department: $dept\n\n
          Phone: $phone\n\n
          Email: $email\n\n
          Project: &project\n\n
          Title: $title\n\n
          Size: $size\n\n
          Qty: $qty\n\n
          CustomSize: $custom\n\n
          DigitalCopy: $digi\n\n
          Printed: $printed\n\n
          Mounted: $mount\n\n
          Comments: $comments\n\n
          RequestDate: $request\n\n
          DeadlineDate: $deadline";

 

And, you just need a ?> to end your php, not a /?>

 

- Josh

 

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/#findComment-1016716
Share on other sites

Thank you very much Seventheyejosh.  I have made all the changes as I understood.  It seems to me that I would want a test loop for each value, so that when someone enters (or doesn't enter) something on a line, it runs the test before letting them move to the next line.  Am I right in assuming that I'd have to make a test loop for each one similar to the "bulk" one that I have here?  That would be a lot of code! 

 

This seems to work now, altho I havent seen output yet, and so havent seen if the test loop is working properly.  at least the error message I'm getting ( PHP Parse error: syntax error, unexpected $end in C:\Inetpub\wwwroot\www.hattiesburgms.com\statefedprograms\confirm.php on line 58 ) appears to be pointing at the last line in my code, which is the </html> line, which mystifies me.  can I just get rid of the html tags?  is that the problem?

 

<html>
<BODY BGCOLOR="#FFFFFF">
<?php 
$name = $_POST["name"];
$org = $_POST["org"];
$dept = $_POST["dept"];
$phone = $_POST["phone"];
$email = $_POST["email"];
$project = $_POST["project"];
$title = $_POST["title"];
$size = $_POST["size"];
$qty = $_POST["qty"];
$digi = $_POST["digi"];
$print = $_POST["print"];
$mount = $_POST["mount"];
$request = $_POST["request"];
$deadline = $_POST["deadline"];

if (!isset ($name) || !isset($org) || !isset($dept) || !isset($phone) || !isset($email) || !isset($project) || !isset($title) || !isset($size) || !isset($qty) || !isset($digi) || !isset($print) || !isset($mount) || !isset($request) || !isset($deadline)){

echo "One of the fields  is invalid or blank, please enter correct information";
echo "<p>";
echo "Please use the 'Back' button to continue.";
echo "</p>";
echo "<a href='#' onclick='self.history.back();'>BACK </a>"; 	
exit();

}else{

$message="Name: $name\n\n
Organization: $org\n\n
Department: $dept\n\n
Phone: $phone\n\n
Email: $email\n\n
Project: &project
Title: $title
Size: $size
Qty: $qty
CustomSize: $custom
DigitalCopy: $digi
Printed: $printed
Mounted: $mount
Comments: $comments
RequestDate: $request
DeadlineDate: $deadline";

mail("[email protected]","$project","$message","From:Form1.$email\r\nReply-to:$email"); 

echo "<p>Thank you for requesting our services. Your details have been forwarded and we will be in contact within 2 working days.</p>";
echo "<p>From: $email</P>";
echo "<p>Subject: $subject</p>";
echo "<p>Message: $message</p>";
echo "<p>";
echo $text;
echo "</p><a href='/gis.html'><b>Return to the GIS Page</b></a>";
?>
</BODY>
</html>

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/#findComment-1016820
Share on other sites

Unexpected $end means just that, your script suddenly ended without any warning. Unlike other php errors, that will never give a helpful line, just the last line in your script (has always for me anyway).

 

If you notice, right before you end php, you don't close your else with a }

 

Your code is like:

 


if($test){

}else{

?> //<-- php goes WTF

 

you need

 


if($test){

}else{

}//end if <-- success!

</body>
</html>

?>

 

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/#findComment-1016844
Share on other sites

TA DA!!!!  I (we) got the page to work!  I took out the part where it did the check on the checkbox fields, and it worked!  I was having a problem with the back button once it was filled out and had a problem, but now that works too.  It is usable.  Thanks a million guys!  The City of Hattiesburg, MS thanks you.  Here is the final code:

 

<html>
<BODY BGCOLOR="#FFFFFF">
<?php 
$name = $_POST["name"];
$org = $_POST["org"];
$dept = $_POST["dept"];
$phone = $_POST["phone"];
$email = $_POST["email"];
$project = $_POST["project"];
$title = $_POST["title"];
$size = $_POST["size"];
$qty = $_POST["qty"];
$digi = $_POST["digi"];
$print = $_POST["print"];
$mount = $_POST["mount"];
$request = $_POST["request"];
$deadline = $_POST["deadline"];

if (!isset ($name) || !isset($org) || !isset($dept) || !isset($phone) || !isset($email) || !isset($project) || !isset($title) || !isset($size) || !isset($qty) || !isset($request) || !isset($deadline)){

echo "One of the fields  is invalid or blank, please enter correct information";
echo "<p>";
echo "Please use the 'Back' button to continue.";
echo "</p>";
echo "<a href='#' onclick='self.history.back();'>BACK </a>"; 	
exit();

}else{
}//end if 

$message="Name: $name\n\n
Organization: $org\n\n
Department: $dept\n\n
Phone: $phone\n\n
Email: $email\n\n
Project: $project
Title: $title
Size: $size
Qty: $qty
CustomSize: $custom
DigitalCopy: $digi
Printed: $printed
Mounted: $mount
Comments: $comments
RequestDate: $request
DeadlineDate: $deadline";

mail("[email protected]","$project","$message","From:Form1.$email\r\nReply-to:$email"); 

echo "<p>Thank you for requesting our services. Your details have been forwarded and we will be in contact within 2 working days.</p>";
echo "<p>From: $email</P>";
echo "<p>Subject: $project</p>";
echo "<p>Message: $message</p>";
echo "<p>";
echo $text;
echo "</p><a href='statefedprograms/gis.html'><b>Return to the GIS Page</b></a>";
?>
</BODY>
</html>

 

Anyone can feel free to adapt the code for their purposes.  It doesn't actually check for phone numbers, just numbers, and same with the date fields (I am not sure what it looks at for email addresses), but I will worry about those another time.

 

Again, thanks for being clear, concise and VERY helpful!  I'd still be pulling out what little hair I have left if not for u guys.

 

peace

Link to comment
https://forums.phpfreaks.com/topic/192955-form-problem/#findComment-1017491
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.