Newbie question - form values showing up

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
therealvibe
Forum Newbie
Posts: 1
Joined: Tue Feb 19, 2008 1:17 pm

Newbie question - form values showing up

Post by therealvibe »

Dear All,

I have just ordered a new server. Because I have only 1 site with minimal php code and a simple database, I decided to install php5 instead of php4 and now I have mysql5 instead of mysql4.

This is the old server info:

http://orbitalnets.com/support/info.php

The new server info:

http://orbnv.tempdomainname.com/support/info.php


I noticed that my forms on the new server are now showing the PHP values of the input form fields.

http://orbnv.tempdomainname.com/index.php?page=contact



On the old server (http://www.odubercontractor.com/index.php?page=contact) this was not the case.

Was this a PHP4 setting to hide the value or something similar?

Or how should I rewrite the code so that it will not show?

Here is the form code:

<?php
if (isset ($_POST['submit'])) {

$name = $_POST['name'] ;
$company= $_POST['company'] ;
$telephone = $_POST['telephone'] ;
$email = $_POST['email'] ;
$message = $_POST['message'] ;

if (ereg("^[a-zA-Z]+[[:space:]]?[a-zA-Z]*[[:space:]]?[a-zA-Z]*$", $name) && ereg("^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+$", $email)){
mail( "info@orbitalnets.com", "Orbitalnets Online Message", '<html> HTML HERE </html>', "From: $email\n"."MIME-Version: 1.0\n" ."Content-type: text/html; charset=iso-8859-1");
header( "Location: index.php?page=success" );
}
else {
if (!ereg("^[a-zA-Z]+[[:space:]]?[a-zA-Z]*[[:space:]]?[a-zA-Z]*$", $name))
$flg_name=1;
if (!ereg("^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)+$", $email))
$flg_email=1;
}

}
?>

And here a snippet of the form:

<label for="name">Name</label>
<input id="name" name="name" type="text" value="<?= $name ?>" size="20" <?php if(!isset($flg_name)) echo ''; else echo 'class="form_error"'; ?> /> <?php if(isset($flg_name)) echo '<div><span class="form_error_text">Please fill in a name</span></div>';?>



Please let me know,



Dwayne
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: Newbie question - form values showing up

Post by Zoxive »

short_open_tag is turned "off" on php5 by default.

Change <?= ?> to <?php echo $Var; ?>
Post Reply