Is anyone willing to help me get the post variable ename followed by the variable $c? The variable c contains the current item I that I am on, and the post variables are all ename1, ename2, ename3(c contains these number). So I want it to print out the post variable that the program is on.
Thanks for all help provided.
Help with this line $_POST[ename$c]
Moderator: General Moderators
Here it is:
<html>
<body bgcolor="999999" text="black">
<div align="left">
<h2>Add Unapreciated person confirmation</h2>
<br>
<?php
$cnt = 0;
if ($_POST[yname] != "") {
echo("For the posters name you entered: <strong>$_POST[yname]</strong><br><br>");
}
if ($_POST[ename1] != "") {
$cnt++;
echo("For unapreciated person #1 you entered: <strong>$_POST[ename1]</strong><br>");
}
if ($_POST[ename2] != "") {
$cnt++;
echo("For unapreciated person #2 you entered: <strong>$_POST[ename2]</strong><br>");
}
if ($_POST[ename3] != "") {
$cnt++;
echo("For unapreciated person #3 you entered: <strong>$_POST[ename3]</strong><br>");
}
if ($cnt == 0)
{
die("You did not fill in any other fields. Please go back: <a href=\"addEform.php\" accesskey=a>Add Unapreciated Person</a>");
}
?>
<p><h3><br>If this information is incorrect then enter the corrected info in the following form.</h3></p>
<form action="addEnemy.php" method="POST">
<?php
echo ("Poster's name: <input type=\"text\" name=yname value=$_POST[yname]><br><br>");
$c = 0;
for ($i = 0;$i < $cnt; $i++)
{
$c++;
echo("Unapreciated person #$c: <input type=\"text\" name=ename$c value=$_POST['ename'.$c]><br><br>");
}
?>
<input type="submit" value="Continue with entered information">
</form>
</div>
</body>
</html>
Now this is meant as sort of a confirmation page for what you filled out in the last form. The last form has 4 input boxes. 1 for your name, and three more titled ename1-3.
<html>
<body bgcolor="999999" text="black">
<div align="left">
<h2>Add Unapreciated person confirmation</h2>
<br>
<?php
$cnt = 0;
if ($_POST[yname] != "") {
echo("For the posters name you entered: <strong>$_POST[yname]</strong><br><br>");
}
if ($_POST[ename1] != "") {
$cnt++;
echo("For unapreciated person #1 you entered: <strong>$_POST[ename1]</strong><br>");
}
if ($_POST[ename2] != "") {
$cnt++;
echo("For unapreciated person #2 you entered: <strong>$_POST[ename2]</strong><br>");
}
if ($_POST[ename3] != "") {
$cnt++;
echo("For unapreciated person #3 you entered: <strong>$_POST[ename3]</strong><br>");
}
if ($cnt == 0)
{
die("You did not fill in any other fields. Please go back: <a href=\"addEform.php\" accesskey=a>Add Unapreciated Person</a>");
}
?>
<p><h3><br>If this information is incorrect then enter the corrected info in the following form.</h3></p>
<form action="addEnemy.php" method="POST">
<?php
echo ("Poster's name: <input type=\"text\" name=yname value=$_POST[yname]><br><br>");
$c = 0;
for ($i = 0;$i < $cnt; $i++)
{
$c++;
echo("Unapreciated person #$c: <input type=\"text\" name=ename$c value=$_POST['ename'.$c]><br><br>");
}
?>
<input type="submit" value="Continue with entered information">
</form>
</div>
</body>
</html>
Now this is meant as sort of a confirmation page for what you filled out in the last form. The last form has 4 input boxes. 1 for your name, and three more titled ename1-3.
if you're in a string literal you need to perform a complex expression replacement.echo("Unapreciated person #$c: <input type=\"text\" name=ename$c value=$_POST['ename'.$c]><br><br>");
In this case try
Code: Select all
echo("Unapreciated person #$c: <input type="text" name=ename$c value={$_POST['ename'.$c]}><br><br>");Code: Select all
echo 'Unapreciated person #', $c, ': <input type="text" name="ename', $c, '" value="', $_POST['ename'.$c], '" /><br /><br />';