PDA

View Full Version : switch ($loc) bugginess



Syous
June 14th, 2007, 01:44 PM
Alright so I have a subscription form that is more horizontal than it is vertical. When the user submits his information I have it set thru php so it says "Message Sent" in place of the form. This works fine on the other pages of the site and in other forms, but for some reasons the table gets out of alignment. Any ideas?

simplistik
June 14th, 2007, 02:43 PM
yea give me a second to try and figure out your html with my fantastical mind reading abilities :smirk:

Syous
June 14th, 2007, 02:57 PM
<div>
<?

switch ($loc){
case sent:


$sendTo = 'david@aslan-studios.com';
$subject = 'Newsletter Sign Up';



$estado = $_POST['estado'];
$zip = $_POST['zip'];
$ciudad = $_POST['ciudad'];
$nombre = $_POST['nombre'];
$apellido = $_POST['apellido'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$workphone = $_POST['workphone'];
$direction = $_POST['direction'];
$actual = $_POST['actual'];

$headers = "From: ". $name . "<" . $email . ">\r\n";
$headers .= "Reply-To: " . $email . "\r\n";
$headers .= "Return-path: ". $email;

$msg = "\r\nNombre: " .$nombre;
$msg .= "\r\nApellido: " .$apellido;
$msg .= "\r\nPhone: " .$phone;
$msg .= "\r\Work Phonel: " .$workphone;
$msg .= "\r\neMail: " .$email;
$msg .= "\r\nCiudad: " .$ciudad;
$msg .= "\r\nEstado: " .$estado;
$msg .= "\r\nZip: " .$zip;
$msg .= "\r\nDirección: " .$direction;
$msg .= "\r\nActual: " .$actual;


if (mail($sendTo,$subject,$msg,$headers))
print "Message Sent";
else
print "Your message was unable to be sent, check for errors and try again";

break;
default:

?>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="176" height="117" style="background:URL(images/tall_y.gif) repeat-y right">
<table border="0" cellspacing="0" cellpadding="0">
<form action="index.php?loc=sent" method="post">
<td valign="top" width="176" height="15"><strong>Nombre/Apellido</strong></td>
</tr>
<tr>
<td valign="top" width="176" height="21"><input name="nombre" type="text" class="input" style="width:137px "></td>
</tr>
<tr>
<td valign="top" width="176" height="24"><input name="apellido" type="text" class="input" style="width:137px "></td>
</tr>
<tr>
<td valign="top" width="176" height="15"><strong>Dirección Actual </strong></td>
</tr>
<tr>
<td valign="top" width="176" height="21"><input name="direction" type="text" class="input" style="width:137px "></td>
</tr>
<tr>
<td valign="top" width="176" height="21"><input name="actual" type="text" class="input" style="width:137px "></td>
</tr>
</table>
</td>
<td valign="top" width="132" height="117" style="background:URL(images/tall_y.gif) repeat-y right">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="9" height="117"></td>
<td valign="top" width="123" height="117">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="123" height="15"><strong>Ciudad/Estado/ZIP</strong></td>
</tr>
<tr>
<td valign="top" width="123" height="21">
<input name="ciudad" type="text" style="width:47px " class="input">
<select name="estado" onChange="MM_jumpMenu('parent',this,0)" class="input" style="width:46px; margin-left:7px ">

<option value="AK">AK</option>

</select>
</td>
</tr>
<tr>
<td valign="top" width="123" height="42"><input name="zip" type="text" style="width:47px " class="input"></td>
</tr>
<tr>
<td valign="top" width="123" height="18"><strong>eMail</strong></td>
</tr>
<tr>
<td valign="top" width="123" height="21"><input name="email" type="text" style="width:107px " class="input"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td valign="top" width="123" height="117">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="12" height="117"></td>
<td valign="top" width="111" height="117">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="111" height="15"><strong>Número Telefónico</strong></td>
</tr>
<tr>
<td valign="top" width="111" height="25"><input name="phone" type="text" style="width:107px " class="input"></td>
</tr>
<tr>
<td valign="top" width="111" height="15"><strong>Teléfono de Trabajo</strong></td>
</tr>
<tr>
<td valign="top" width="111" height="41"><input name="workphone" type="text" style="width:107px " class="input"></td>
</tr>
<tr>
<td valign="top" width="111" height="29"><input name="send" type="image" src="images/apply.gif" style="margin-left:56px "> <?
}
?></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</div>

It's messy. I cut out the long list of drop downs to save space for your sake if you choose to read this. 8)

joran420
June 14th, 2007, 03:13 PM
if its working its not the php...lets see how you are sending the data to php...

i have a feeling if you tried to trace any of the $_POST when it doesnt work they would all come back undefined....

Syous
June 14th, 2007, 04:06 PM
PHP works fine, it's just when ever it prints the "Messeage Sent" text in place of the form the rest of the tables on the page go wacky. No idea what you mean by trace any of the $_POST though.

Voetsjoeba
June 14th, 2007, 04:30 PM
On a side note, your script is extremely vulnerable to e-mail header injection, which sooner or late you will fall victim to - and you don't want that to happen. Read up on it here (http://www.securephpwiki.com/index.php/Email_Injection).

simplistik
June 14th, 2007, 04:48 PM
switch this:


...
if (mail($sendTo,$subject,$msg,$headers))
print "Message Sent";
else
print "Your message was unable to be sent, check for errors and try again";

break;
default:

?>
<table border="0" cellspacing="0" cellpadding="0">
...
to


...
$message = '';
if (mail($sendTo,$subject,$msg,$headers))
$message = "Message Sent";
else
$message = "Your message was unable to be sent, check for errors and try again";

break;
default:
?>

<? if ( !empty($message) ) { ?>
<div id="message" style="width: 100%;"><? echo $message; ?></div>
<? } ?>
<table border="0" cellspacing="0" cellpadding="0">
...

when you just do a straight print on the page it's just doing that... printing to the page, it holds no actual styling attributes so it can screw up your crap, just like it is. at least... that's what I think the problem is...