This is two pages below is 1.php commit after jump to 2.php then jump to 1.php I use 360 browser submitted after the direct display page does not exist what is going on? There's nothing in the database, I'm a newbie, I might have a lot of mistakes, everybody, help me out.
This is 1.php.
$db = new PDO (' Mysql:host=localhost;dbname=t1 ', ' root ', ', ' array (Pdo::mysql_attr_init_command = = ' SET NAMES ' UTF8 ') );
$rs = $db Prepare ("SELECT * from ' Baidu ';");
$rs, execute ();
$list = Fetchall (PDO::FETCH_ASSOC), $rs;
?>
foreach ($list as $v) {
echo $v [' type ']. '
';
echo $v [' name ']. '
';
echo $v [' num ']. '
';
echo $v [' site ']. '
';
echo $v [' content ']. '
';
}
?>
This is 2.php.
$pdo =new PDO ("Mysql:host=localhost;dbname=t1", "Root", "");
if ($pdo->exec ("INSERT into Baidu" (
Type
Name
Num
Site
Content
)
VALUES (
' Select ', ' name ', ' num ', ' site ', ' content '
)")){
echo "";
}
?>
Reply to discussion (solution)
Look at the URL on the address bar.
What about the results of your site directory and the location of the two files?
Look at the URL on the address bar.
What about the results of your site directory and the location of the two files?
All in the WWW directory no problem URL is http://localhost/2.php
Look at the URL on the address bar.
What about the results of your site directory and the location of the two files?
I opened the 2.php alone.
Look at the URL on the address bar.
What about the results of your site directory and the location of the two files?
I just carelessly put that 2.php file outside, so I don't show it now I put it in the WWW directory, but after the data is submitted successfully, it doesn't show what I just submitted.
And why isn't the data inserted in the database a value of name?
Look at the URL on the address bar.
What about the results of your site directory and the location of the two files?
I just carelessly put that 2.php file outside, so I don't show it now I put it in the WWW directory, but after the data is submitted successfully, it doesn't show what I just submitted.
And why isn't the data inserted in the database a value of name?
Because your 2.php SQL does not add $ write is constant
$pdo =new PDO ("Mysql:host=localhost;dbname=t1", "Root", "");
if ($pdo->exec ("INSERT into Baidu" (
Type
Name
Num
Site
Content
)
VALUES (
' Select ', ' name ', ' num ', ' site ', ' content '
)")){
echo "";
}
You insert the string yourself, of course that is the result. You did not get the values submitted by the form.
The value of the post is not passed. I changed it to (
' $_post[select] ', ' $_post[name] ', ' $_post[num] ', ' $_post[site] ', ' $_post[content '
) "And why not?
$pdo =new PDO ("Mysql:host=localhost;dbname=t1", "Root", "");
if ($pdo->exec ("INSERT into Baidu" (
Type
Name
Num
Site
Content
)
VALUES (
' Select ', ' name ', ' num ', ' site ', ' content '
)")){
echo "";
}
You insert the string yourself, of course that is the result. You did not get the values submitted by the form.
The value of the post is not passed. I changed it to (
' $_post[select] ', ' $_post[name] ', ' $_post[num] ', ' $_post[site] ', ' $_post[content '
) "And why not?
Changed to this, the inserted content or the original ones.
(' $_post[select] ', ' $_post[name] ', ' $_post[num] ', ' $_post[site] ', ' $_post[content ') ')
Print_r ($_post) in 2.php; Look at the results.
Change it to the following, try it.
(' {$_post[' select '} ', ' {$_post[' name ']} ', ' {$_post[' num '} ', ' {$_post[' site '} ', ' {$_post[' content '} ') ')
Print_r ($_post) in 2.php; Look at the results.
Change it to the following, try it.
(' {$_post[' select '} ', ' {$_post[' name ']} ', ' {$_post[' num '} ', ' {$_post[' site '} ', ' {$_post[' content '} ') ')
Change to you like this or not print_r ($_post); Is this sentence in front of Echo? I've tried it for nothing. I'm going to put echo out of the way, and I'm just writing this sentence.
You've got a problem with this SQL notation.
Honestly, splice the SQL statement string.
Print_r ($_post) in 2.php; Look at the results.
Change it to the following, try it.
(' {$_post[' select '} ', ' {$_post[' name ']} ', ' {$_post[' num '} ', ' {$_post[' site '} ', ' {$_post[' content '} ') ')
Change to you like this or not print_r ($_post); Is this sentence in front of Echo? I've tried it for nothing. I'm going to put echo out of the way, and I'm just writing this sentence.
Add in the first line to see if there is no value.
Print_r ($_post);
Exit ();
$pdo =new PDO ("Mysql:host=localhost;dbname=t1", "Root", "");
.....
Print_r ($_post) in 2.php; Look at the results.
Change it to the following, try it.
(' {$_post[' select '} ', ' {$_post[' name ']} ', ' {$_post[' num '} ', ' {$_post[' site '} ', ' {$_post[' content '} ') ')
Change to you like this or not print_r ($_post); Is this sentence in front of Echo? I've tried it for nothing. I'm going to put echo out of the way, and I'm just writing this sentence.
Add in the first line to see if there is no value.
Print_r ($_post);
Exit ();
$pdo =new PDO ("Mysql:host=localhost;dbname=t1", "Root", "");
.....
I just tried it from work.