Jump to content

Confused... Strings returning numbers...


Gibbs

Recommended Posts

I'm really confused. To test that i'm getting the right information from the forms i've printed them...

Any help would be great!

This is how i'm getting the info:
[code=php:0]include("include/session.php");
$userx = $session->username; // Get the username logged in

$perform = $_GET['perform']; // Get the perform URL
$table = "bio"; // The table to read and write to

// Get the employee details (if they submit them)
$firstname = $_POST[bio_fname];
$secondname = $_POST['bio_sname'];
$age = $_POST['bio_age'];
$gender = $_POST['bio_gender'];
$birth = $_POST['bio_birth'];
$residence = $_POST['bio_residence'];
$bio = $_POST['bio_bio'];
$education = $_POST['bio_education'];
$training = $_POST['bio_training'];[/code]

This is the form etc...
[code=php:0]if ($perform==add)
{
echo "<p>Welcome $userx. Please submit accurate and correct information only. If you make any mistakes or your details change you may update your entry at any time. <br>Thank you.<br></p>
<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<form action=\"vtxemp.php?perform=submit1337\" method=\"post\">
<tr>
<td width=\"115\" height=\"25\"><p align=\"right\">First name: </p></td>
<td width=\"385\">
<input name=\"bio_fname\" type=\"text\" class=\"textpm\"></td>
</tr>
<tr>
<td height=\"25\"><p align=\"right\">Second Name: </p></td>
<td><input name=\"bio_sname\" type=\"text\" class=\"textpm\"></td>
</tr>
<tr>
<td height=\"25\"><p align=\"right\">Age: </p></td>
<td><input name=\"bio_age\" type=\"text\" class=\"textpm\" size=\"2\" maxlength=\"2\"></td>
</tr>
<tr>
<td height=\"25\"><p align=\"right\">Gender: </p></td>
<td>
<select name=\"bio_gender\" class=\"dropdownl\">
<option value=\"Male\">Male</option>
<option value=\"Female\">Female</option>
</select></td>
</tr>
<tr>
<td height=\"25\"><p align=\"right\">Place of Birth: </p></td>
<td><input name=\"bio_birth\" type=\"text\" class=\"textpm\"></td>
</tr>
<tr>
<td height=\"25\"><p align=\"right\">Current Residence: </p></td>
<td><input name=\"bio_residence\" type=\"text\" class=\"textpm\"></td>
</tr>
<tr>
<td valign=\"top\"><p align=\"right\">Employee Bio: </p></td>
<td><label>
<textarea name=\"bio_bio\" cols=\"60\" rows=\"10\" class=\"textpm\"></textarea>
</label></td>
</tr>
<tr>
<td valign=\"top\"><p align=\"right\">Education: </p></td>
<td><textarea name=\"bio_education\" cols=\"60\" rows=\"4\" class=\"textpm\"></textarea></td>
</tr>
<tr>
<td valign=\"top\"><p align=\"right\">Training: </p></td>
<td><textarea name=\"bio_training\" cols=\"60\" rows=\"4\" class=\"textpm\"></textarea></td>
</tr>
<tr>
<td valign=\"top\">&nbsp;</td>
<td><label>
<input type=\"submit\" name=\"Submit\" value=\"Submit Entry\">
</label></td>
</tr>
</form>
</table>";
}

if ($perform==submit1337)
{
echo $firstname or die("First name not entered");
echo $secondname or die("Second name not entered");
echo $age or die("Age not entered");
echo $gender or die("Gender not entered");
echo $birth or die("Place of Birth not entered");
echo $residence or die("Current Residence");
echo $bio or die("Employee Biography not entered");
echo $education or die("Education details not entered");
echo $training or die("Training details not entered");

//$create = "INSERT INTO $table (firstName, secondName, age, gender, placeBirth, cResidence, bio, education, training, username)
//VALUES ('$firstname','$secondname','$age','$gender','$birth','$residence', '$bio', '$education', '$training')";
//$create2 = mysql_query($create) or die("Database Entry Failed");
//echo("<br><br>Thank you. Your details have been submitted to the Vortex Network Employee Database");
}[/code]

I'm so confused as to whats going wrong.... Please help!

Thank you :)
Link to comment
Share on other sites

$perform==submit1337 etc work.

These are being returned as the number 1 after submitting the form...

[code]$firstname = $_POST[bio_fname];
$secondname = $_POST['bio_sname'];
$age = $_POST['bio_age'];
$gender = $_POST['bio_gender'];
$birth = $_POST['bio_birth'];
$residence = $_POST['bio_residence'];
$bio = $_POST['bio_bio'];
$education = $_POST['bio_education'];
$training = $_POST['bio_training'];[/code]
Link to comment
Share on other sites

[quote author=jesirose link=topic=123041.msg508204#msg508204 date=1169162128]
add this
?><pre><?
print_r($_POST);
?></pre><?
before here: $firstname = $_POST['bio_fname'];

And tell me what it prints.
[/quote]

It prints "Array ( )"

Edit: I'm using a lot of includes on this page. Could they be conflicting (although everything else is working...)?
Link to comment
Share on other sites

Sorry still new to this.

[quote]Array ( [bio_fname] => Name [bio_sname] => Name [bio_age] => 32 [bio_gender] => Male [bio_birth] => London [bio_residence] => Devon [bio_bio] => TEST [bio_education] => TEST [bio_training] => TEST [Submit] => Submit Entry )[/quote]

Looks like that worked...

What can I do with this info, or what does it indicate?
Link to comment
Share on other sites

Your problem is in this section of code:
[code]<?php
echo $firstname or die("First name not entered");
echo $secondname or die("Second name not entered");
echo $age or die("Age not entered");
echo $gender or die("Gender not entered");
echo $birth or die("Place of Birth not entered");
echo $residence or die("Current Residence");
echo $bio or die("Employee Biography not entered");
echo $education or die("Education details not entered");
echo $training or die("Training details not entered");
?>[/code]

That is not the correct way of doing this check. Remove the "or die" clauses.

Ken
Link to comment
Share on other sites

Just a quick note. if you output [nobbc]"<pre></pre>"[/nobbc] tags before and after the "print_r", the output is much easier to read.

[code]<?php
echo '<pre>' . print_r($_POST,true) . '</pre>';
?>[/code]

I usually put it into a function, so i can pass it any variable I want to see dumped:
[code]<?php
function dumpvar($var,$str='')
{
    if (!empty($var))
          echo "<pre>$str " . print_r($var,true) . '</pre>';
}

dumpvar($_POST,'$_POST');
dumpvar($_SESSION,'$_SESSION');

?>[/code]

Ken
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.