![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Jul 2004
Location: Location
Posts: 138
Rep Power: 4
![]() |
Parsing PHP script output
Hi everyone,
I have been recently working on a PHP script that e-mails form data to a specific user. The script works fine, although I have a question. Below is what is e-mailed to me upon completion of the form: A customer has submitted a New Unit Warranty Registration. The details can be found below.
Array
(
[Customer_Name] => bulio
[E-Mail] => sampleemail@domain.com
[Model] => SB-III SR+
[Serial_Number] => 4564045542
[Engine_Hours] => 4664
[Part_that_Caused_Failure] => Alternator
[Repair_Order] => 533-511
[Cause_of_Claim_Code] => Unknown
[Cause_of_Failure_Code] => Unknown
[Correction_Code] => 5463-354
[Job_Code] => 2883116
[body] => Alternator stopped working.
)My question is, how do I remove the Array () and the [] which is around the Model etc. fields? I assume I need to use a parser, but I haven't seen any examples of how this would be done. I use print_r to pass the form data on to the email script. Below is my code: form.html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thermo King New Unit Warranty Registration</title>
</head>
<body>
<h1>Thermo King New Unit Warranty Registration</h1>
<p><strong>Unit Information:</strong></p>
<form action='mail.php' method='post'>
<p>Name:
<input type='text' name='name'>
</p>
<p>E-Mail:
<input type='text' name='email'>
</p>
<p>Model and Type:
<input type='text' name='model'>
<br>
</p>
<p>Serial Number:
<input type='text' name='serialnum'>
<br>
</p>
<p>Engine hours:
<input type='text' name='enginehrs'>
</p>
<p>Part that caused failure:
<input type='text' name='failedpart'>
</p>
<p>Repair order:
<input type='text' name='repairorder'>
</p>
<p>Cause of claim code:
<input type='text' name='causeclaimcode'>
</p>
<p>Cause of failure code:
<input type='text' name='causefailcode'>
</p>
<p>Correction code:
<input type='text' name='correctioncode'>
</p>
<p>Job code:
<input type='text' name='jobcode'>
</p>
<p>
Written detail of cause of failure: <textarea name='body'></textarea><br>
</p>
<p><br>
<input type='submit' value='Submit'>
</p>
</form>
</body>
</html>mail.php <?php $to = "person@domain.com.com"; $subject = "New Unit Warranty Registration"; $message = print_r($_POST, true); $headers = "From: $email"; $from = "warranty@domain.ca\nX-Mailer: PHP 4.x" mail($to, $subject, $message, $headers, $from); echo "Thanks for submitting." ?> |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Jul 2004
Location: Location
Posts: 138
Rep Power: 4
![]() |
Re: Parsing PHP script output
Nevermind, I fixed it by removing print_r and using something else.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bulletin Board PHP Script | grimpirate | Existing Project Development | 0 | Aug 28th, 2007 1:28 AM |
| Php Tutorial 3 | bulio | PHP | 4 | Jul 16th, 2006 4:00 AM |
| A simple perl script | satimis | Perl | 3 | Aug 15th, 2005 9:31 AM |
| script to obtain jpgs and compress them and save them to an output file | Jimineep | Bash / Shell Scripting | 2 | May 18th, 2005 9:16 AM |
| Script to output HDD data to serial port | Europa2010AD | C | 2 | Apr 6th, 2005 1:37 PM |