search
HomeBackend DevelopmentPHP Tutorial我这个代码点击提交后的为什么页面显示不存在?

我这个代码点击提交后的为什么页面显示不存在?

Jun 20, 2016 pm 12:42 PM
Why does the page show that it does not exist after I click submit with this code?

这是两个页面  下面是1.php  提交后跳转到2.php 再跳转到1.php  我用360的浏览器提交后直接显示页面不存在  是怎么回事? 数据库也没有任何东西    我是新手 可能有很多错误 大家帮我看看吧  谢谢  
     
 
这是1.php  
6c24d8bfbe01a7f21ec2ea2ab3502d6b "SET NAMES 'utf8'"));  
 $rs = $db -> prepare("select * from `baidu`;");  
 $rs -> execute();  
 $list = $rs -> fetchAll(PDO::FETCH_ASSOC);  
?>  
100db36a723c770d327fc0aef2ce13b1  
93f0f5c25f18dab9d176bd4f6de5d30e  
9c3bca370b5104690d9ef395f2c5f8d1  
6c04bd5ca3fcae76e30b72ad730ca86d  
a6e374fd6c27f4b9d1f6db7dfd9d5066  
  07e7ad40b7e0294061a1e7902eb890a5';  
      echo $v['name'].'ff9d32c555bb1d9133a29eb4371c1213';  
      echo $v['num'].'ff9d32c555bb1d9133a29eb4371c1213';  
      echo $v['site'].'ff9d32c555bb1d9133a29eb4371c1213';  
      echo $v['content'].'ff9d32c555bb1d9133a29eb4371c1213';  
    }  
  ?>  
16b28748ea4df4d9c2150843fecfba68  
64cb571ed5952d9b43da1f2d70a36e91  
      74901cacd564e38eb2276799e268a219  
          dc6dce4a544fdca2df29d5ac0ea9906b  
            b801c4a2bdeb64b5ff46f909bddadfde  
              5a07473c87748fb1bf73f23d45547ab8请选择4afa15d3069109ac30911f04c56f3338  
              5a07473c87748fb1bf73f23d45547ab81114afa15d3069109ac30911f04c56f3338  
              5a07473c87748fb1bf73f23d45547ab82224afa15d3069109ac30911f04c56f3338  
              5a07473c87748fb1bf73f23d45547ab83334afa15d3069109ac30911f04c56f3338  
              5a07473c87748fb1bf73f23d45547ab84444afa15d3069109ac30911f04c56f3338  
            18bb6ffaf0152bbe49cd8a3620346341  
            7ff07d2c0e347c2583e0a1ec4cdd7e70  
            05cfd628a6e302e1083e9e9876a47e44  
            6b14f126bfa81b93ff3cd2cab165933c  
          16b28748ea4df4d9c2150843fecfba68  
          7f7ad4e3848bcb5bb0d5629c8339c01740587128eee8df8f03d0b607fe983014ff9d32c555bb1d9133a29eb4371c1213  
          f20d061a3899a134aedcb04673a6fa89发布65281c5ac262bf6d81768915a4a77ac0  
      f5a47148e367a6035fd7a2faa965022e  
16b28748ea4df4d9c2150843fecfba68  
36cc49f0c466276486e50c850b7e4956  
73a6ac4ed44ffec12cee46588e518a5e  
 
这是2.php  
f0bbd60121afca66d1aefb1b3e0552c4exec("INSERT INTO baidu(  
type,  
name,  
num,  
site,  
content  
)  
VALUES (  
'select','name','num','site','content'  
)")){  
echo "3f1c4e4b6b16bbbd69b2ee476dc4f83aalert('发布成功');location='1.php';2cacc6d41bbb37262a98f745aa00fbf0";  
}  
?>

回复讨论(解决方案)

看看地址栏上的网址是什么?  
还有,你的站点目录结果及这两个文件所在的位置是怎么样的?


看看地址栏上的网址是什么?  
还有,你的站点目录结果及这两个文件所在的位置是怎么样的?


都在www目录下 没有问题  网址也是http://localhost/2.php    
 


看看地址栏上的网址是什么?  
还有,你的站点目录结果及这两个文件所在的位置是怎么样的?


 
我单独打开2.php也显示不错在  怎么回事


看看地址栏上的网址是什么?  
还有,你的站点目录结果及这两个文件所在的位置是怎么样的?


 
我刚才粗心把那个2.php的文件放到外面了 所以不显示  现在我放到www目录下了  但是数据提交成功后显示不出来刚才提交的内容呢   
而且为什么数据库里面不是插入的数据呢  都是name的值呢  




看看地址栏上的网址是什么?    
还有,你的站点目录结果及这两个文件所在的位置是怎么样的?


 
我刚才粗心把那个2.php的文件放到外面了 所以不显示  现在我放到www目录下了  但是数据提交成功后显示不出来刚才提交的内容呢   
而且为什么数据库里面不是插入的数据呢  都是name的值呢  

因为你2.php的sql没有加$  写的是常量

$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 "3f1c4e4b6b16bbbd69b2ee476dc4f83aalert('发布成功');location='1.php';2cacc6d41bbb37262a98f745aa00fbf0";  
}  
 
你自己插入的就是字符串,当然就是那个结果。你并没有获取表单提交过来的值。

post的值没有传过去  我改成(  
'$_POST[select]','$_POST[name]','$_POST[num]','$_POST[site]','$_POST[content]'  
)")  怎么还是不行啊  
 

$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 "3f1c4e4b6b16bbbd69b2ee476dc4f83aalert('发布成功');location='1.php';2cacc6d41bbb37262a98f745aa00fbf0";  
}  
 
你自己插入的就是字符串,当然就是那个结果。你并没有获取表单提交过来的值。


 
post的值没有传过去  我改成(  
'$_POST[select]','$_POST[name]','$_POST[num]','$_POST[site]','$_POST[content]'  
)")  怎么还是不行啊  

改成这样了    插入的内容还是原来的那些  
   
('$_POST[select]','$_POST[name]','$_POST[num]','$_POST[site]','$_POST[content]')") 

在2.php 中 print_r($_POST); 看看结果。  
 
改成下面这样试试看  

('{$_POST['select']}','{$_POST['name']}','{$_POST['num']}','{$_POST['site']}','{$_POST['content']}')")

  


在2.php 中 print_r($_POST); 看看结果。  
 
改成下面这样试试看  

('{$_POST['select']}','{$_POST['name']}','{$_POST['num']}','{$_POST['site']}','{$_POST['content']}')")

  


 
改成你这样了 还是不行  print_r($_POST);这句话加在echo前面吗  试了一下 什么都没有 我把echo注释掉 只写这一句 怎么还是弹出来提交成功 然后还和原来一样

你这个SQL写法都有问题的。  
老老实实拼接SQL语句字符串吧。




在2.php 中 print_r($_POST); 看看结果。    
   
改成下面这样试试看    

('{$_POST['select']}','{$_POST['name']}','{$_POST['num']}','{$_POST['site']}','{$_POST['content']}')")

  


 
改成你这样了 还是不行  print_r($_POST);这句话加在echo前面吗  试了一下 什么都没有 我把echo注释掉 只写这一句 怎么还是弹出来提交成功 然后还和原来一样
加在首行先看下有不有值。  
print_r($_POST);  
exit();  
$pdo=new PDO("mysql:host=localhost;dbname=t1","root","");  
.....  





在2.php 中 print_r($_POST); 看看结果。    
   
改成下面这样试试看    

('{$_POST['select']}','{$_POST['name']}','{$_POST['num']}','{$_POST['site']}','{$_POST['content']}')")

  


   
改成你这样了 还是不行  print_r($_POST);这句话加在echo前面吗  试了一下 什么都没有 我把echo注释掉 只写这一句 怎么还是弹出来提交成功 然后还和原来一样
加在首行先看下有不有值。  
print_r($_POST);  
exit();  
$pdo=new PDO("mysql:host=localhost;dbname=t1","root","");  
.....  

 
我刚下班 试了一下 还是 不行 和原来一样

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What are the advantages of using a database to store sessions?What are the advantages of using a database to store sessions?Apr 24, 2025 am 12:16 AM

The main advantages of using database storage sessions include persistence, scalability, and security. 1. Persistence: Even if the server restarts, the session data can remain unchanged. 2. Scalability: Applicable to distributed systems, ensuring that session data is synchronized between multiple servers. 3. Security: The database provides encrypted storage to protect sensitive information.

How do you implement custom session handling in PHP?How do you implement custom session handling in PHP?Apr 24, 2025 am 12:16 AM

Implementing custom session processing in PHP can be done by implementing the SessionHandlerInterface interface. The specific steps include: 1) Creating a class that implements SessionHandlerInterface, such as CustomSessionHandler; 2) Rewriting methods in the interface (such as open, close, read, write, destroy, gc) to define the life cycle and storage method of session data; 3) Register a custom session processor in a PHP script and start the session. This allows data to be stored in media such as MySQL and Redis to improve performance, security and scalability.

What is a session ID?What is a session ID?Apr 24, 2025 am 12:13 AM

SessionID is a mechanism used in web applications to track user session status. 1. It is a randomly generated string used to maintain user's identity information during multiple interactions between the user and the server. 2. The server generates and sends it to the client through cookies or URL parameters to help identify and associate these requests in multiple requests of the user. 3. Generation usually uses random algorithms to ensure uniqueness and unpredictability. 4. In actual development, in-memory databases such as Redis can be used to store session data to improve performance and security.

How do you handle sessions in a stateless environment (e.g., API)?How do you handle sessions in a stateless environment (e.g., API)?Apr 24, 2025 am 12:12 AM

Managing sessions in stateless environments such as APIs can be achieved by using JWT or cookies. 1. JWT is suitable for statelessness and scalability, but it is large in size when it comes to big data. 2.Cookies are more traditional and easy to implement, but they need to be configured with caution to ensure security.

How can you protect against Cross-Site Scripting (XSS) attacks related to sessions?How can you protect against Cross-Site Scripting (XSS) attacks related to sessions?Apr 23, 2025 am 12:16 AM

To protect the application from session-related XSS attacks, the following measures are required: 1. Set the HttpOnly and Secure flags to protect the session cookies. 2. Export codes for all user inputs. 3. Implement content security policy (CSP) to limit script sources. Through these policies, session-related XSS attacks can be effectively protected and user data can be ensured.

How can you optimize PHP session performance?How can you optimize PHP session performance?Apr 23, 2025 am 12:13 AM

Methods to optimize PHP session performance include: 1. Delay session start, 2. Use database to store sessions, 3. Compress session data, 4. Manage session life cycle, and 5. Implement session sharing. These strategies can significantly improve the efficiency of applications in high concurrency environments.

What is the session.gc_maxlifetime configuration setting?What is the session.gc_maxlifetime configuration setting?Apr 23, 2025 am 12:10 AM

Thesession.gc_maxlifetimesettinginPHPdeterminesthelifespanofsessiondata,setinseconds.1)It'sconfiguredinphp.iniorviaini_set().2)Abalanceisneededtoavoidperformanceissuesandunexpectedlogouts.3)PHP'sgarbagecollectionisprobabilistic,influencedbygc_probabi

How do you configure the session name in PHP?How do you configure the session name in PHP?Apr 23, 2025 am 12:08 AM

In PHP, you can use the session_name() function to configure the session name. The specific steps are as follows: 1. Use the session_name() function to set the session name, such as session_name("my_session"). 2. After setting the session name, call session_start() to start the session. Configuring session names can avoid session data conflicts between multiple applications and enhance security, but pay attention to the uniqueness, security, length and setting timing of session names.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.