Jump to content

Format text from form


Aosto

Recommended Posts

I'm trying to format text from a form. I am working on an application that will take user input from a form and send it to the scrip and then print it in a certain format. The problem is it asks multiple question and not all the information will be used. In our company we use Alert finds that have to be formatted a certain way for the system to read them correctly. Here is a sample output (some information left out)

 

O - I. Outage - Des Moines, IA - Description of outage here. Impact: I. 400.

 

Here is the problem I have. I can get the rest up to impact and then I don't what to do. We have multiple things that can be impacted but they aren't always included on the alerts and I don't know how to get it to print the impact, below is what I have so far.

 

Form Date

<html>
<body>

<form action="alertformat.php" method="post" name="alert">
Select Type:<br />
Open: <input name="open" type="radio" value="O" />
Update: <input name="update" type="radio" value="U" />
Close: <input name="close" type="radio" value="C" /><br />
<select name="outagetype" size="7">
<option value="I. Outage">I. Outage</option>
<option value="I. P. Outage">I. P. Outage</option>
<option value="I. P. V. Outage">I. P. V. Outage</option>
<option value="I. P. Ent. Outage">I. P. Ent. Outage</option>
<option value="I. Ent. Outage">I. Ent. Outage</option>
<option value="Tools Outage">Tools Outage</option>
<option value="Office Outage">Office Outage</option>
</select>
<br />
Impacted Tool, Office, or Location.<br />
<input name="iarea" type="text" value="" maxlength="100" /><br />
Description.<br />
<input name="description" type="text" value="" size="100" maxlength="255" /><br />
Impacts:<br />
I.<input name="icount" type="text" value="" maxlength="20" /><br />
P.<input name="pcount" type="text" value="" maxlength="20" /><br />
Ent.<input name="entcount" type="text" value="" maxlength="20" /><br />
V.<input name="vcount" type="text" value="" maxlength="20" /><br />
Other: <input name="other" type="text" value="" maxlength="100" /><br />
Office Count: <input name="ocount" type="text" value="" maxlength="20" /><br />
<input name="" type="submit" />

</form>

</body>
</html>

 

And here is my PHP

<?php 

$open = $_POST["open"];
$update = $_POST["update"];
$close = $_POST["close"];
$outagetype = $_POST["outagetype"];
$iarea = $_POST["iarea"];
$description = $_POST["description"];
$icount = $_POST["icount"];
$pcount = $_POST["pcount"];
$entcount = $_POST["entcount"];
$vcount = $_POST["vcount"];
$other = $_POST["other"];
$ocount = $_POST["ocount"];

$i = $icount . "I. ";
$p = $pcount . "P. ";
$e = $entcount . "Ent. ";
$v = $vcount . "V. ";
$o = $ocount . "Office. ";



echo "$open $update $close - $outagetype - $iarea - $description. Impact: ";

?>

 

I am new with PHP so any help would be appreciated, thanks in advanced.

Link to comment
https://forums.phpfreaks.com/topic/196555-format-text-from-form/
Share on other sites

Figured it out :) I'm happy, here is my code now..Just requires some clean up and that i'm sure I can do.

<?php 
$open = $_POST["open"];
$update = $_POST["update"];
$close = $_POST["close"];
$outagetype = $_POST["outagetype"];
$iarea = $_POST["iarea"];
$description = $_POST["description"];
$icount = $_POST["icount"];
$pcount = $_POST["pcount"];
$entcount = $_POST["entcount"];
$vcount = $_POST["vcount"];
$other = $_POST["other"];
$ocount = $_POST["ocount"];

$i = $icount . " I. ";
$p = $pcount . " P. ";
$e = $entcount . " Ent. ";
$v = $vcount . " V. ";
$o = $ocount . " Office. ";



echo "$open $update $close - $outagetype - $iarea - $description. D - Impact:" . " ";

if (is_numeric($icount)) {
echo "$i";
}

if (is_numeric($pcount)) {
echo "$p";
}

if (is_numeric($entcounr)) {
echo "$e";
}

if (is_numeric($vcount)) {
echo "$v";
}

if (is_numeric($ocount)) {
echo "$o";
}

echo " $other NU - ";

?>

 

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.