Jump to content

[SOLVED] form isnt passing my variable?


aebstract

Recommended Posts

Hey guys, been awhile since I have been around these parts, but I am having a little trouble.

I got a form with two simple inputs. I put a check at the top of my page to see if the field has information entered or not. Well it is returning false when it has information and when it doesn't.

 

Here is what I have:  (file - account2.php)

 

<?php
session_start();
header("Cache-control: private");

if (isset ($_POST['submit'])) {
$problem = FALSE;



if (empty ($_POST['plantloc'])) {
$problem = TRUE;
$error .= 'Must enter a plant location<br />';
}







mysql_connect("*","*","*");
mysql_select_db("*");


if (!$problem) {

$plantloc  = $_POST['plantloc'];

$length = 6;
$password = "";
$possible = "0123456789bcdfghjkmnpqrstvwxyz"; 
$i = 0; 
    
while ($i < $length) { 
    $char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
    if (!strstr($password, $char)) { 
      $password .= $char;
      $i++;
    }

  }

$password2 = md5($_POST['password1']);
$address = $_POST['address'];


$result = MYSQL_QUERY("INSERT INTO plants (plantloc,password,address)".
"VALUES ('$plantloc, '$password2', '$address,')");


$sendmail = "
$password2
";

mail ('tcantwell@berryequipment.net', 'Thank You', $sendmail, 'From: aebstract@gmail.com');



} else {
$content .= "$error";
}
}
?>

 

 

 

 

and the form area:

 


<?php
$content .= '<form action="account2.php?menu=create" method="post">
<br />
Plant Location: <br /><input type="text" maxlength="100" class="textfield" name="username" size="40" value="' . $_POST[plantloc] . '" /><br /><br />

Address:<br />
<textarea cols="50" rows="4" name="address" value="' . $_POST[address] . '"></textarea>
<br /><br />

<input type="submit" name="submit" value="submit" class="textfield" /></form>';



echo "$content";
?>

Link to comment
Share on other sites

I noticed you seem to be missing a '}'

 

<?php
if (isset ($_POST['submit'])) {
    $problem = FALSE;
}      //This was missing


if (empty ($_POST['plantloc'])) {
    $problem = TRUE;
    $error .= 'Must enter a plant location<br />';
}
?>

 

 

Link to comment
Share on other sites

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.