Jump to content

Recommended Posts

I have been working on a custom form for our office to use, and I am rounding the final corner (checkboxes!) and am stuck.

 

I have finally gotten the code to actually function the way I want, but am greeted with a 500 error instead of the confirmation page.  Maybe I'm just tired and missing something...

 

HTML:

<form name="htmlform" method="post" action="html_form_send.php">
<p><center><font size="18">Tucker Arensberg IT Equipment Request Form</font></center></p>
<center><b><font color="red">Please Fill Out Entire Form, IT Department Is Not Responsible For Incomplete Information On Requests.</font></b></center><br>
<table width="450px">
</tr>
<tr>
 <td valign="top">
  <label for="first_name"><b>First Name:</b></label>
 </td>
 <td valign="top">
  <input  type="text" name="first_name" maxlength="50" size="30">
 </td>
</tr>
 
<tr>
 <td valign="top"">
  <label for="last_name"><b>Last Name:</b></label>
 </td>
 <td valign="top">
  <input  type="text" name="last_name" maxlength="50" size="30">
 </td>
</tr>
<tr>
 <td valign="top">
  <label for="email"><b>Email Address:</b><br>
</label>
 </td>
 <td valign="top">
  <input  type="text" name="email" maxlength="80" size="30">
<br><b><font color="red">FULL EMAIL MUST BE ENTERED OR FORM WILL NOT BE SUBMITTED</font></b><br> 
</td>

 
</tr>
<tr>
 <td valign="top">
  <label for="daterequest"><b>Pickup Date:</b><br>
	(mm/dd/yyyy)<br>
<br>
</label>
 </td>
 <td valign="top">
  <input  type="text" name="daterequest" maxlength="10" size="10">
 </td>
</tr>

<tr>
 <td valign="top">
  <label for="datereturn"><b>Estimated Return Date:</b><br>
	(mm/dd/yyyy)<br>
<br>
</label>
 </td>
 <td valign="top">
  <input  type="text" name="datereturn" maxlength="10" size="10">
 </td>
</tr>

<tr>
            <td valign="top"">
                <b><label class="radio" for="usage">Usage:</label></b>
            </td>
            <td valign="top">
                <input class="radio" type="radio" name="usage" value="internal" checked /> <span>Internal (On-Site)</span><br>
                <input class="radio" type="radio" name="usage" value="external" /> <span>External (Off-Site)</span><br><br>
            </td>


<tr>
 <td valign="top">
  <label for="equipment"><b>Equipment Needed:</b><br>
	(Any items not checked will not be included)</label>
 </td>
 <td valign="top">
 <input type="checkbox" name="equipment" value="Laptop" /> Laptop<br />
 <input type="checkbox" name="equipment" value="Carrying Case" /> Carrying Case<br />
 <input type="checkbox" name="equipment" value="Mouse" /> Mouse<br />
 <input type="checkbox" name="equipment" value="Hotspot" /> HotSpot/MiFi/Portable WiFi Device<br />
 <input type="checkbox" name="equipment" value="usb" /> USB Thumb Drive<br />
 <input type="checkbox" name="equipment" value="Vodka" /> Vodka<br />
<br>
<br>
 </td>
</tr>

<tr>
 <td valign="top">
  <b>Laptop Features Required:</b><br>
	(Any items not checked cannot be guaranteed on laptop)
 </td>
 <td valign="top">
 <input type="checkbox" name="features[]" value="cd" /> CD Drive<br />
 <input type="checkbox" name="features[]" value="dvd" /> DVD Drive<br />
 <input type="checkbox" name="features[]" value="vpn" /> VPN Connection<br />
 <input type="checkbox" name="features[]" value="netilla" /> Netilla<br />
 <input type="checkbox" name="features[]" value="media" /> Media Playback (video files)<br>
(Please include extension/format of video/audio files in COMMENTS section.)<br />
 <input type="checkbox" name="features[]" value="vmware" /> VMWare<br />
<br>
<br>
 </td>
</tr>

<tr>
 <td valign="top">
  <label for="comments"><b>Additional Comments:</b></label>
 </td>
 <td valign="top">
  <textarea  name="comments" maxlength="1000" cols="25" rows="6"></textarea>
 </td>
 
</tr>
<br>
<br>
<tr>
 <td colspan="2" style="text-align:center">
  <input type="submit" value="Submit">
 </td>
</tr>
</table>
</form>
<br>
<br>
<center><img src='logo.jpg'>
<br>
Copyright 2015 Tucker Arensberg IT Department</center>

PSP:

<?php
 
if(isset($_POST['email'])) {
 
     
 
    // EDIT THE 2 LINES BELOW AS REQUIRED
 
    $email_to = "blank@blank.com";
 
    $email_subject = "New Equipment Checkout Request";
 
     
 
     
 
    $first_name = $_POST['first_name']; // required
 
    $last_name = $_POST['last_name']; // required
 
    $email_from = $_POST['email']; // required
 
    $daterequest = $_POST['daterequest']; // not required
 
    $datereturn = $_POST['datereturn'];

    $usage = $_POST['usage'];   

    $features .= implode(', ', $_POST['features']);



    $comments = $_POST['comments']; // required

    $comments = $_POST['comments']; // required
 
 
 
    $email_message = "Form details below.\n\n";
 
     
 
    function clean_string($string) {
 
      $bad = array("content-type","bcc:","to:","cc:","href");
 
      return str_replace($bad,"",$string);
 
    }
 
     
 
    $email_message .= "First Name: ".clean_string($first_name)."\n";
 
    $email_message .= "Last Name: ".clean_string($last_name)."\n";
 
    $email_message .= "Email: ".clean_string($email_from)."\n";
 
    $email_message .= "Date Requested: ".clean_string($daterequest)."\n";
 
    $email_message .= "Estimated Return Date: ".clean_string($datereturn)."\n";

    $email_message .= "Usage: ".clean_string($usage)."\n";

    $email_message .= "Features Requested: ".clean_string($features)."\n";




   // $email_message .= "Estimated Return Date: ".clean_string($datereturn)."\n";

   // $email_message .= "Comments: ".clean_string($comments)."\n";
 
     
 
     
 
// create email headers
 
$headers = 'From: '."requests@tuckerlaw.com"."\r\n".
 
'Reply-To: '.$email_from."\r\n" .
 
'X-Mailer: PHP/' . phpversion();
 
@mail($email_to, $email_subject, $email_message, $headers);  
 
?>
 
 
 
<!-- include your own success html here -->
 
 
 
Thank you for contacting us. We will be in touch with you very soon.
 
 
 
<?php
 
}
 
?>

Of note, when I comment out the assignment and email-print for the "$features" variable, it runs without emailing the checkboxes, and gives the proper "confirmation" page.

 

Thanks! 

 

but am greeted with a 500 error instead of the confirmation page.

Check you servers error logs for why you are getting that error. Or add the following two lines at the top of your script (after the <?php)

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

 

Check you servers error logs for why you are getting that error. Or add the following two lines at the top of your script (after the <?php)

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

There is nothing for today in any of my Event Viewer logs, and adding that code results in the same error page.  

 

There is nothing for today in any of my Event Viewer logs,

As in Windows Event Viewer? It wont be logged in there. The servers error log will be text file. For example the Apache http server writes it errors to a file called error.log in a directory called logs. The logs folder will be where you installed Apache to (eg C:/Apache/logs).

 

You will not be able to solve 500 Internal Server without knowing the actual error that is triggering it.

As in Windows Event Viewer? It wont be logged in there. The servers error log will be text file. For example the Apache http server writes it errors to a file called error.log in a directory called logs. The logs folder will be where you installed Apache to (eg C:/Apache/logs).

 

You will not be able to solve 500 Internal Server without knowing the actual error that is triggering it.

I am using IIS 7.5.  I have the error_log directory in PHP.ini set to C:\ and its not creating a file.

 

This is what's in \inetpub\logs

#Software: Microsoft Internet Information Services 7.5
#Version: 1.0
#Date: 2015-03-04 15:51:30
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
2015-03-04 15:51:30 172.16.1.9 POST /html_form_send.php - 80 - 172.16.5.45 Mozilla/5.0+(Windows+NT+6.3;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/40.0.2214.115+Safari/537.36 500 0 0 826
2015-03-04 15:51:57 172.16.1.9 GET / - 80 - 172.16.5.45 Mozilla/5.0+(Windows+NT+6.3;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/40.0.2214.115+Safari/537.36 200 0 0 0
2015-03-04 15:51:57 172.16.1.9 GET /logo.jpg - 80 - 172.16.5.45 Mozilla/5.0+(Windows+NT+6.3;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/40.0.2214.115+Safari/537.36 304 0 0 46
2015-03-04 15:52:03 172.16.1.9 POST /html_form_send.php - 80 - 172.16.5.45 Mozilla/5.0+(Windows+NT+6.3;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/40.0.2214.115+Safari/537.36 500 0 0 296
#Software: Microsoft Internet Information Services 7.5
#Version: 1.0
#Date: 2015-03-04 15:56:53
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
2015-03-04 15:56:53 172.16.1.9 POST /html_form_send.php - 80 - 172.16.5.45 Mozilla/5.0+(Windows+NT+6.3;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/40.0.2214.115+Safari/537.36 500 0 0 218
2015-03-04 15:59:29 172.16.1.9 POST /html_form_send.php - 80 - 172.16.5.45 Mozilla/5.0+(Windows+NT+6.3;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/40.0.2214.115+Safari/537.36 500 0 0 218
#Software: Microsoft Internet Information Services 7.5
#Version: 1.0
#Date: 2015-03-04 16:03:36
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken
2015-03-04 16:03:36 172.16.1.9 POST /html_form_send.php - 80 - 172.16.5.45 Mozilla/5.0+(Windows+NT+6.3;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/40.0.2214.115+Safari/537.36 500 0 0 202
Edited by mjanosko

Umm.. Nope does not seem to be any errors logged there, more of an access log really. I'm not an IIS user so not sure where it logs its errors to.

 

Have you tried setting these lines in the php.ini

error_reporting = E_ALL
display_errors = On

Make sure you restart IIS after making any changes in the php.ini. This should force errors to be displayed during run time.

Umm.. Nope does not seem to be any errors logged there, more of an access log really. I'm not an IIS user so not sure where it logs its errors to.

 

Have you tried setting these lines in the php.ini

error_reporting = E_ALL
display_errors = On

Make sure you restart IIS after making any changes in the php.ini. This should force errors to be displayed during run time.

Enabled both of these, restarted IIS, loaded page from a browser I don't use (to avoid completely closing my browser and clearing cache), same thing.  Generic 500 error.  Nothing more.  

$features .= implode(', ', $_POST['features']);

Did you mean if you comment out that line, it works?

 

Try without the dot. 

 

Also, for security, make sure you html escape the strings - the inputs may contain malicious JavaScript.  Use htmlspecialchars() for this.

$features .= implode(', ', $_POST['features']);

Did you mean if you comment out that line, it works?

 

Try without the dot. 

 

Also, for security, make sure you html escape the strings - the inputs may contain malicious JavaScript.  Use htmlspecialchars() for this.

 

Couldn't care any less about security, it's internal only, and to be honest I imagine most users will tell me to get f##ked before they actually use it, but thanks!

 

Yeah, when I comment out that line and "

 
    $email_message .= "Features Requested: ".clean_string($features)."\n"; 
it runs fine.  It runs fine NOW, just returns a 500 error, but the email stills come through perfectly.  
 
Removing the "." did not change anything.  Same exact results.  :( 

I am using IIS 7.5.  I have the error_log directory in PHP.ini set to C:\ and its not creating a file.

error_log needs to point to a file, not a directory. Set it to something like C:\php_errors.txt. Make sure the file is writable by IIS as well.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • 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.