POST方式的表单,在客户端用Chrome改成GET方式,为什么有的能提交成功,有的不能?

我们这里的车管所网站是有验证码的,POST方式。不过验证码是客户端的JS脚本生成的,在浏览器里用JS脚本验证成功后修改一个隐藏域值。我在Chrome里把表单改成GET方式,提交之后保存URL,以后就可以直接访问,不用再填写表单了。

但是其他一些网站,把POST方式改成GET方式之后提交不上。

POST方式的表单,在客户端用Chrome改成GET方式,为什么有的能提交成功,有的不能?

2个回答

这个取决于服务端的处理,一般服务端会区分POST,GET请求,如果你直接更换,不一定能正确地支持。
POST,GET在http中有不同的语义,不能随便替换

如果服务器端先用getMethod()判断请求方法的话,就由不得你随意把post改成get了。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
表单内部与POST数组交互

<div class="post-text" itemprop="text"> <p>Okay my code is not broken, however it can be improved. I have a form element inside a table, which, according to this post <a href="https://stackoverflow.com/questions/5967564/form-inside-a-table">here</a> is illegal, but for me it is working to some extent. I am using PHP and the situation is as follows:</p> <p>Inside that form I have two elements one is <code>comment</code> and another is <code>order_date</code>; when I inspect the form in chrome developer tools it shows the correct structure, so the point in the earlier linked post is not happening here. When the form gets submitted, I can never get the values of these fields from the post array unless I initialize them first, I am initializing them within a <code>$_SESSION</code>, what is weird is that when I initialize them using <code>$_POST</code> it also does not work. What is causing this error? Thanks</p> <p>code for initializing them:</p> <pre><code>if(empty($_SESSION['comment'])) { $_SESSION['comment']=''; } if(empty($_SESSION['order_date'])) { $_SESSION['order_date']=''; } </code></pre> <p>code for getting their value after form is submitted:</p> <pre><code>if(isset($_POST['comment']) &amp;&amp; isset($_POST['order_date'])) { $_SESSION['comment'] = nl2br(filter_var($_POST['comment'],FILTER_SANITIZE_STRING)); $_SESSION['order_date'] = mysqli_real_escape_string($con,$_POST['order_date']); } </code></pre> <p>Trying to get their value in:</p> <pre><code>if(isset($_POST["place_order"])) { $comment = $_POST['comment']; } </code></pre> <p>The above code doesn't work</p> <p>This is the table row of the form:</p> <pre><code>&lt;tr&gt; &lt;td colspan="5" align="center"&gt; &lt;form method="POST" action="cart.php" class="form-group"&gt; &lt;label for="comment"&gt;Order comments &lt;/label&gt; &lt;textarea name="comment" id="comment" class="form-control" placeholder="Please enter any special instructions for the order" required&gt; &lt;?php if (isset($_SESSION['comment'])) { echo $_SESSION['comment']; } ?&gt; &lt;/textarea&gt; &lt;br&gt; &lt;label for="order_date"&gt;Delivery date&lt;/label&gt; &lt;input type="date" class="form-control" style="max-width: 20%;" name="order_date" id="date" required&gt;&lt;/input&gt; &lt;br /&gt; &lt;input type="submit" name="place_order" id="place_order" class="btn logo-green" value="Place Order" /&gt; &lt;/form&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>Thank you</p> </div>

一个用来post表单的javascript在FireFox能成功,在IE7上却不行

大家就帮个忙 javacript是这样的 [code="js"] <script type="text/javascript"> $(document).ready(function(){ var myform = document.getElementById("loginform"); myform.method="POST"; myform.action="login.php"; myform.target="variframe"; myform.submit(); }); </script> [/code] 表单是这样的 [code="html"] <iframe frameborder="0" name="variframe" id="variframe" width="0" height="0"></iframe> <form id="loginform"> <input type="text" value="admin" id="user_login" name="log"/> <input type="password" value="test" id="user_pass" name="pwd"/> </form> [/code] 我是想让这个页面加载完成后自动的向一个登录文件login.php发送用户名和密码登录,并且显示在一个iframe里,这样不会导致页面离开当前页,这样写后能在Firefox, Opera, Chrome, Safari里执行,但是不能在ie上执行。 在ie(我只测试了ie7)上执行的时候可以看到页面加载了一瞬间的login.php,然后就停止了,而在其他浏览器上請求的时间要长一些。 google了一下,没有发现IE在这上面有什么特别的,有什么想法告诉我一下,谢谢 [b]问题补充:[/b] 感觉lovewhzlq的帮忙,不过还是不行,这样改了后,在Firefox上会直接跳到login.php上了,而IE却会报错,错误就在改的那个代码那,谢谢。 另外不一定要用这种方法,如果能给我提供一个方法能够把一个表单提交到两个php文件就行了。 [b]问题补充:[/b] [color=brown]怎么不能对别人的回答进行回复啊,再次感謝lovewhzlq的帮助,这次在Firefox上没有错误,执行成功了,可是在IE上依然报错,而且也是不能post,错误是在 document.getElementById("variframe").appendChild(myform); 说的是参数不正确[/color] [b]问题补充:[/b] 谢谢pan_java和lovewhzlq,这样还是不行,不知道有没有什么其他的办法呢? IE只是請求login.php非常短的时间 [b]问题补充:[/b] 回pan_java,我现在几乎不会js,也就是想实现这一个功能。用onload事件結果都是一样的,IE只是請求那个login.php一小会的时间,似乎請求没有发送成功还是怎么着 [b]问题补充:[/b] 回复lovewhzlq,这样也是只能在Firefox上有用。。。我也无奈了,找了几个别人的IE测试了下也是一样的,IE8和IE7都不行。 [b]问题补充:[/b] 回lovewhzlq和pan_java, 还是不行,一样的結果,就是IE没反应,其他都行,依然非常感謝你们。。。 [b]问题补充:[/b] 回复pan_java,这些方法我又都试了一下,发现其实只要这个登录文件在本地,这些方法都行,因为IE那一点的請求时间就足够了,但是当login文件在另一个地方的时候就不行了,IE依然只請求那一点时间,所以不能完成工作。 谢谢你 [b]问题补充:[/b] 谢谢lovewhzlq给出那么长的代码,不过依然不行,我无奈了,不这样做了,问题结束吧,没有正确答案,但是我还是想把分给帮助我的两位,就采纳给我回答的最多的那个答案吧

ionic3 http请求更改headers post请求出错

我ionic3中设置http请求,后台为webapi,get请求没问题,post不带参数也能请求, 添加参数就报错,要么405要么415,更改ContenT_Type好像没起作用,增加tonken后台也是无法获取值,有哪位大神 遇到过知道怎么解决吗? //token验证 var headers = new Headers(); headers.append('Content-Type', 'application/json'); headers.append('Authorization', 'weixiao-token');//这里添加了token let options = new RequestOptions(JSON.stringify({ headers: headers })); this.http.request('http://localhost:6112/api/UserInfo/Login',options) .subscribe((res:Response)=>{ console.log(res.json()); }); ``` 后台获取到的是null //post带参数 let headers =new Headers({ "Content-Type":"application/x-www-form-urlencoded"}) let body =JSON.stringify({name:"chuanzhi"}) let reqO = new RequestOptions({headers:headers}) this.http.post("http://localhost:23909/api/Cs/postPaths", body,reqO) .subscribe((res:Response)=>{ console.log(res.json()); }) 在chrome中查看没有变化Content-Type:application/json; charset=utf-8 报错 发现参数在request payload中,报错415然后想到去掉JSON.stringify(),找不到参数了,并且报错405 这是后台的接口,试过去掉[FromBody]也没用,实在没辙了 [Route("api/Cs/postPaths")] [HttpPost] public string postPaths([FromBody]string name) { return name; } 刚开始学,希望前辈指教下

plUpload与多个实例提交表单提交

<div class="post-text" itemprop="text"> <p>I have looked on here and other sites at many examples of plUpload. I have taken code from these examples and have got different forms working but none will do exactly what i'm looking for - fingers crossed you guys will help me find a solution.</p> <p>I currently have a data entry form made up of table rows with each row allowing uploading of an image. This form is submitted to PHP and the images/data stored.</p> <p>I'm wanting to move the image upload routines over to plUpload to work better with older/more browsers and allowing client image resize etc.</p> <p>From what i can see I need a mix of the core plUpload and the jQuery module to allow for instances to be bound via a class rather than an id but I went down that route and hit a brick wall. I've now been looking at another two bits of code found on here (sorry I've forgot the author name) and have come up with the below.</p> <pre><code>&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="../js/plupload.full.min.js"&gt;&lt;/script&gt; &lt;form id="form" action="" multipart method="post"&gt; &lt;div id="container1" class="gallery"&gt; &lt;a id="pickfiles1" href="javascript:;"&gt;[Select files]&lt;/a&gt; &lt;a id="uploadfiles1" href="javascript:;"&gt;[Upload files]&lt;/a&gt; &lt;/div&gt; &lt;div id="container2" class="gallery"&gt; &lt;a id="pickfiles2" href="javascript:;"&gt;[Select files]&lt;/a&gt; &lt;a id="uploadfiles2" href="javascript:;"&gt;[Upload files]&lt;/a&gt; &lt;/div&gt; &lt;input type="submit" /&gt;&lt;/input&gt; &lt;/form&gt; &lt;p&gt;&lt;label&gt;Debug data:&lt;/label&gt;&lt;div id="debug"&gt;&lt;/div&gt;&lt;/p&gt; &lt;div id="uploaded"&gt;&lt;/div&gt; &lt;script&gt; function initUploader(itemIndex) { var uploader1 = new plupload.Uploader({ runtimes: 'html5,html4,flash,silverlight,browserplus', browse_button: 'pickfiles'+itemIndex, container: 'container'+itemIndex, max_file_size: '10mb', max_retries: 3, chunk_size: '1mb', url: 'upload.php', unique_names: false, preserve_headers: false, flash_swf_url: 'http://www.plupload.com/plupload/js/plupload.flash.swf', silverlight_xap_url: 'http://www.plupload.com/plupload/js/plupload.silverlight.xap', filters: [ { title: "Image files", extensions: "jpg,gif,png"} ], resize: {width : 320, height : 240, quality : 90} }); uploader1.bind('Init', function(up, params) { $('#filelist'+itemIndex).html("&lt;div&gt;Current runtime: " + params.runtime + "&lt;/div&gt;"); }); $('#uploadfiles'+itemIndex).click(function(e) { uploader1.start(); e.preventDefault(); }); uploader1.init(); uploader1.bind('UploadProgress', function(up, file) { $('#' + file.id + " b").html(file.percent + "%"); }); uploader1.bind('Error', function(up, err) { $('#filelist'+itemIndex).append("&lt;div&gt;Error: " + err.code + ", Message: " + err.message + (err.file ? ", File: " + err.file.name : "") + "&lt;/div&gt;" ); up.refresh(); // Reposition Flash/Silverlight }); uploader1.bind('FilesAdded', function(up, files) { $.each(files, function(i, file) { $('#debug').prepend('Uploading ' + file.name + ' (' + file.size + ' bytes)'); }); // up.refresh(); // up.start(); }); uploader1.bind('FileUploaded', function(up, file) { // $('#' + file.id + " b").html("100%"); $('#uploaded').prepend('&lt;p&gt;&lt;a href="' + public_url + file.name + '" target="_blank"&gt;&lt;img src="' + public_url + file.name + '" width="100"/&gt;&lt;/a&gt;&lt;/p&gt;'); }); } $('#form').submit(function(e) { // Files in queue upload them first alert("Submit"); var uploader = $('#container2').plupload('getUploader'); // Validate number of uploaded files if (uploader.total.uploaded == 0) { // Files in queue upload them first if (uploader.files.length &gt; 0) { // When all files are uploaded submit form uploader.bind('UploadProgress', function () { $('#uploader1').on('complete', function() { alert("Complete - wait for rest"); $('#form').submit(); }); }); $('#uploader1').plupload('start'); } else { $('#form').submit();} //alert('You must at least upload one file.'); e.preventDefault(); } else { $('#form').submit();} }); initUploader(1); initUploader(2); &lt;/script&gt; </code></pre> <p>The routine will allow me to selet files but I can't submit them on form submit..</p> <p>Any help to point me in the right direction would be appreciated.</p> </div>

HTML表单可以在IE上发布,但无法使用Firefox和Chrome发送(大多数)值?

<div class="post-text" itemprop="text"> <p>Relatively simple form - nothing fancy - </p> <p>Post goes thru exactly as expected with I.E. v11 and Edge .</p> <p>However - with Chrome and Firefox - ONLY two hidden fields come thru, the rest of the post results are null/empty. </p> <p>Convert to GET and I get the same results. </p> <p>This is a straightforward HTML form using a submit button, and the action is a straightforward php script that collects the field values and inserts them into a MySQL database. Old school stuff. </p> <p>I'm bewildered at this point.</p> </div>

禁用选择选项的简单HTML表单允许在Chrome和IE中提交。 在Firefox中正常工作

<div class="post-text" itemprop="text"> <p>I have a simple HTML form that submits to another page. Select options are being used with one being 'disabled' and 'selected'. In Chrome and Internet Explorer this form is allowed to be submitted, but in Firefox it works correctly and tells me to select an option.</p> <p>Code:</p> <pre><code>&lt;form name=cars method=post action=submit.php&gt; &lt;select required&gt; &lt;option value="volvo" disabled="disabled" selected&gt;Volvo&lt;/option&gt; &lt;option value="saab"&gt;Saab&lt;/option&gt; &lt;option value="vw"&gt;VW&lt;/option&gt; &lt;option value="audi"&gt;Audi&lt;/option&gt; &lt;input type=submit value=submit name=submit&gt; &lt;/select&gt; &lt;/form&gt; </code></pre> <p>In FireFox, as expected, when I hit the submit button, I get the message:</p> <p>"Please Select an item in the list."</p> <p>On IE and Chrome it tries to submit to the submit page.</p> </div>

使用javascript生成表单元素并将它们发布到php可以在EI中使用,而不是在Chrome和Firefox中

<div class="post-text" itemprop="text"> <p>I can't get my head around this problem. I have a page on which there is a form generated by php. Then I'm using Javascript to track number of selected checkboxes and in a real time generating a text with this information as well hidden input with this very same value I tried to use both jQuery and raw Javascript.</p> <pre><code>var message=first+'&lt;input name="first_credit" type="hidden" value="'+first+'"/&gt;'; $('#render_second').html(message).show(); document.getElementById('render_second').innerHTML = message; </code></pre> <p>The value that is stored in variable first gets displayed correctly in all browsers, but when I post the form only in EI I get the value of first_credit. In FireFox and Chrome its as if that hidden element is not a part of form. </p> <p>Thank you for your time chaps.</p> <p>And here is the solution ... I opened the table tag, then the form opening tag and then trs and tds one of which contained the div in to which I was rendering the input field. All I did is, first open the form tag and then table tag and it all works fine :-) Sorry to waste your time folks...</p> </div>

Chrome提供在注册表单上保存密码 - Ajax

<div class="post-text" itemprop="text"> <p>I have a registration form and when everything checks out and the registration button (submit button for the form) is clicked, it runs all of the following code. the /xhrCreateUser method in my PHP controller further validates, sanitizes, and inserts the POST data into a database. For simple error checking for now, if the echo from the /xhrCreateUser method is <code>true</code>, then it alerts the user that the account has been created and it redirects the page. However, when the redirect method is called, the browser offers to save the password when the user is redirected. I would like this behavior to happen on something like a login form, but not a registration form. If the redirect is not called, the Offer to save the password does not trigger, so obviously it is that that is triggering chrome to offer to save the password. I don't get why this is happening, it does not do employ this behavior in Firefox. Is it something to do with me posting the value of a password input element or something?</p> <p>I imagine chrome does this to support ajax login forms, but its also doing this on my registration form, which is not ideal.</p> <pre><code>register.addEventListener('click', function(e){ if(validateName(0)){ if(validateName(1)){ if(validateUsername(2)){ if(validateEmail(3)){ if(validatePassword(4)){ //Start XML HTTP Account Insertion var xmlhttp; if(window.XMLHttpRequest){ xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function register(){ if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200){ var result = xmlhttp.responseText; console.log(result); if(result.indexOf('true') &gt; -1){ alert("Account has been created, you will be redirected"); redirect(); //redirect } else { alert("Something went wrong, that's all we know. Please refresh the page and try again."); } } } xmlhttp.open("POST", "user/xhrCreateUser", true); xmlhttp.setRequestHeader("Content-type","application/json"); xmlhttp.send(JSON.stringify({firstname:firstname.value, lastname:lastname.value, username:username.value, email:email.value, password:password.value})); } else { //password is bad //toggle error classes for CSS here forceError(4); password.focus(); } } else { //email is bad //toggle error classes for CSS here forceError(3); email.focus(); } } else { //username is bad //toggle error classes for CSS here forceError(2); username.focus(); } } else { //lastname is bad //toggle error classes for CSS here forceError(1); lastname.focus(); } } else { //firstname is bad //toggle error classes for CSS here forceError(0); firstname.focus(); } }); </code></pre> </div>

PHP联系表单在FF中不起作用,但在Edge IE chrome和safari中工作

<div class="post-text" itemprop="text"> <p>Dear folks the following code could be perfectly executed in IE (newest), Edge, Chrome and Safari but times out in FF, also it has issues with displaying the form in firefox.</p> <p>In Firefox once i press submit, it starts running the sendform.php it executes correctly, <strong>but it gets stuck once everything is filled out properly and it should send the form / email to me</strong>.</p> <p>the page is also in use. Tips and tricks for better / more secure code is appreciated.</p> <p>The contact from code ( as in kontakt.php):</p> <pre><code>&lt;?php session_start(); $success=''; if($_SESSION['sent'] == '1') { $success='&lt;div class="container"&gt; &lt;h3&gt;Vielen Dank. Ihre Nachricht wurde übermittelt.&lt;/h3&gt; &lt;/div&gt;'; $css='&lt;style type="text/css"&gt;#phpcontactform{display:none;}&lt;/style&gt;'; unset($_SESSION['sent']); } ?&gt; &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --&gt; &lt;meta name="keywords" content="mieten,Bruchsal,Vermietung,Büro,Hallen,Standort,Industrie,Gewerbe,Gewerbepark,Produktion,Karlsruhe"&gt; &lt;meta name="description" content="Vermietung von Büro, Hallen, Lager- und Produktionsflächen im Gewerbepark Bruchsal. Lageplan und Hallenplan."&gt; &lt;meta name="robots" content="INDEX,FOLLOW"&gt; &lt;meta name="page-topic" content="Kontaktformular"&gt; &lt;title&gt;GWB Kontakt&lt;/title&gt; &lt;link href="files/bootstrap.min.css" rel="stylesheet"&gt; &lt;link href="files/main.css" rel="stylesheet"&gt; &lt;?=$css?&gt; &lt;script type="text/javascript" src="files/jquery-1.11.3.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="files/bootstrap.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="files/myaffix.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function () { //code for dynamic navbar banner myaffix(); $(window).on("resize", function () { myaffix(); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="logo"&gt; &lt;img class="featurette-image img-responsive center-block" src="images/banner.jpg" alt="Generic Banner"&gt; &lt;/div&gt; &lt;div id="placeme"&gt; &lt;/div&gt; &lt;div id="nav-wrapper"&gt; &lt;div id="nav" class="navbar navbar-inverse"&gt; &lt;div class="container"&gt; &lt;div class="navbar-header"&gt; &lt;button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"&gt; &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;span class="icon-bar"&gt;&lt;/span&gt; &lt;/button&gt; &lt;a class="navbar-brand" href="index.html"&gt;Gewerbepark Bruchsal&lt;/a&gt; &lt;/div&gt; &lt;div id="navbar" class="navbar-collapse collapse"&gt; &lt;ul class="nav navbar-nav"&gt; &lt;li&gt;&lt;a href="standort.html"&gt;Standort&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="bilder.html"&gt;Bilder&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="hallenplan.html"&gt;Hallenplan&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="ausstattung.html"&gt;Ausstattung&lt;/a&gt;&lt;/li&gt; &lt;li class="active"&gt;&lt;a href="kontakt.php"&gt;Kontakt&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="container"&gt; &lt;h1&gt;Kontakt&lt;/h1&gt; &lt;hr&gt; &lt;p&gt;ARES GmbH, Richard-Wagner-Straße 23, 50674 Köln &lt;br&gt;Telefon: 0221-2717290, Fax: 0221-2717291, Email: &lt;a href="mailto:info@gewerbepark-bruchsal.de"&gt;info@gewerbepark-bruchsal.de&lt;/a&gt; &lt;/p&gt; &lt;hr size="5px"&gt; &lt;div class="container"&gt; &lt;h2&gt;Schreiben Sie uns direkt an&lt;/h2&gt; &lt;form id="phpcontactform" class="form-horizontal" role="form" method="post" action="files/sendform.php"&gt; &lt;div class="form-group &lt;?php if (isset($_SESSION['err']['name'])) {if ($_SESSION['err']['name'] == 'okay') {echo 'has-success has-feedback';} else {echo 'has-error has-feedback';}} ?&gt; "&gt; &lt;label class="control-label col-sm-2" for="name"&gt;Name:&lt;/label&gt; &lt;div class="col-sm-10"&gt; &lt;input type="text" class="form-control &lt;?php if (isset($_SESSION['err']['name'])) {if ($_SESSION['err']['name'] == 'okay') {echo 'alert alert-success';} else {echo 'alert alert-danger';}} ?&gt;" name="name" id="name" placeholder="Ihr Name" maxlength="100" value="&lt;?php echo ($_SESSION['post']['name']); ?&gt;"&gt; &lt;?php if (isset($_SESSION['err']['name'])) {if ($_SESSION['err']['name'] == 'okay') {echo "&lt;span class='glyphicon glyphicon-ok form-control-feedback'&gt;&lt;/span&gt;";} else {echo "&lt;span class='glyphicon glyphicon-remove form-control-feedback'&gt;&lt;/span&gt;&lt;p class='text-danger'&gt;{$_SESSION['err']['name']}&lt;/p&gt;";} }?&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group &lt;?php if (isset($_SESSION['err']['email'])) {if ($_SESSION['err']['email'] == 'okay') {echo 'has-success has-feedback';} else {echo 'has-error has-feedback';}} ?&gt;"&gt; &lt;label class="control-label col-sm-2" for="email"&gt;Email:&lt;/label&gt; &lt;div class="col-sm-10"&gt; &lt;input type="email" class="form-control &lt;?php if (isset($_SESSION['err']['email'])) {if ($_SESSION['err']['email'] == 'okay') {echo 'alert alert-success';} else {echo 'alert alert-danger';}} ?&gt;" name="email" id="email" placeholder="Ihre Emailadresse" value="&lt;?php echo ($_SESSION['post']['email']); ?&gt;"&gt; &lt;?php if (isset($_SESSION['err']['email'])) {if ($_SESSION['err']['email'] == 'okay') {echo "&lt;span class='glyphicon glyphicon-ok form-control-feedback'&gt;&lt;/span&gt;";} else {echo "&lt;span class='glyphicon glyphicon-remove form-control-feedback'&gt;&lt;/span&gt;&lt;p class='text-danger'&gt;{$_SESSION['err']['email']}&lt;/p&gt;";} }?&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label class="control-label col-sm-2" for="telefon"&gt;Telefon:&lt;/label&gt; &lt;div class="col-sm-10"&gt; &lt;input type="tel" class="form-control" name="telefon" id="telefon" placeholder="Ihre Telefonnummer - für schnellere Rücksprache" maxlength="50" value="&lt;?php echo ($_SESSION['post']['telefon']); ?&gt;"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group &lt;?php if (isset($_SESSION['err']['message'])) {if ($_SESSION['err']['message'] == 'okay') {echo 'has-success has-feedback';} else {echo 'has-error has-feedback';}} ?&gt;"&gt; &lt;label class="control-label col-sm-2" for="message"&gt;Nachricht:&lt;/label&gt; &lt;div class="col-sm-10"&gt; &lt;textarea class="form-control &lt;?php if (isset($_SESSION['err']['message'])) {if ($_SESSION['err']['message'] == 'okay') {echo 'alert alert-success';} else {echo 'alert alert-danger';}} ?&gt;" name="message" id="message" placeholder="Ihr Anliegen" maxlength="1000"&gt;&lt;?php echo ($_SESSION['post']['message']); ?&gt;&lt;/textarea&gt; &lt;?php if (isset($_SESSION['err']['message'])) {if ($_SESSION['err']['message'] == 'okay') {echo "&lt;span class='glyphicon glyphicon-ok form-control-feedback'&gt;&lt;/span&gt;";} else {echo "&lt;span class='glyphicon glyphicon-remove form-control-feedback'&gt;&lt;/span&gt;&lt;p class='text-danger'&gt;{$_SESSION['err']['message']}&lt;/p&gt;";} }?&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;div class="col-sm-offset-2 col-sm-10"&gt; &lt;button type="submit" name="senden" id="btn-senden" class="btn btn-lg btn-warning"&gt;Senden&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;?=$success?&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="container"&gt; &lt;hr&gt; &lt;footer&gt; &lt;p&gt;&amp;copy; 2015 ARES GmbH &lt;a href="impressum.html"&gt;Impressum&lt;/a&gt;&lt;/p&gt; &lt;/footer&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The submit code ( as in sendform.php):</p> <pre><code> &lt;?php //SMTP needs accurate times, and the PHP time zone MUST be set //This should be done in your php.ini, but this is how to do it if you don't have access to that // date_default_timezone_set('Etc/UTC'); //Create a new PHPMailer instance require "phpmailer/PHPMailerAutoload.php"; session_start(); foreach($_POST as $k=&gt;$v) { if(ini_get('magic_quotes_gpc')) $_POST[$k]=stripslashes($_POST[$k]); $_POST[$k]=htmlspecialchars(strip_tags($_POST[$k])); } // Fehlerkontrolle // kreiere Fehlerarray $err = array(); // Füge entsprechende Fehler hinzu if(!checkLen('name')) $err['name']='Sie haben keinen Namen angegeben.'; else $err['name']='okay'; if(!checkLen('email')) $err['email']='Sie haben keine Email angegeben.'; elseif(!checkEmail($_POST['email'])) $err['email']='Die Email scheint nicht gültig zu sein.'; else $err['email']='okay'; if(!checkLen('message')) $err['message']='Sie haben keine Nachricht hinterlassen.'; else $err['message']='okay'; // Speichere variablen in Seitenübergreifender Variable (SESSION) $_SESSION['post']=$_POST; $_SESSION['err']=$err; //check if there are no errors if(count(array_unique($err)) === 1) { //create message body $msg= 'Name: '.$_POST['name'].'&lt;br /&gt; Email: '.$_POST['email'].'&lt;br /&gt; IP: '.$_SERVER['REMOTE_ADDR'].'&lt;br /&gt;&lt;br /&gt; Message:&lt;br /&gt;&lt;br /&gt; '.nl2br($_POST['message']).' '; //Create a new PHPMailer instance $mail = new PHPMailer; //Tell PHPMailer to use SMTP $mail-&gt;isSMTP(); //Set the hostname of the mail server $mail-&gt;Host = 'smtp.XXXXX.XXX'; // use // $mail-&gt;Host = gethostbyname('smtp.gmail.com'); // if your network does not support SMTP over IPv6 //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission $mail-&gt;Port = 587; //Set the encryption system to use - ssl (deprecated) or tls $mail-&gt;SMTPSecure = 'tls'; //Whether to use SMTP authentication $mail-&gt;SMTPAuth = true; //Username to use for SMTP authentication - use full email address for gmail $mail-&gt;Username = "XXXX@XXXXX.XXX"; //Password to use for SMTP authentication $mail-&gt;Password = "XXXXXXXXX"; //Set who the message is to be sent from $mail-&gt;setFrom($_POST['email'], $_POST['name']); //Set an alternative reply-to address $mail-&gt;addReplyTo('replyto@example.com', 'First Last'); //Set who the message is to be sent to $mail-&gt;addAddress('XXXX@XXXX.XXX', 'Kontakt Formular'); //Set the subject line $mail-&gt;Subject = "Eine Anfrage von ".$_POST['name']."."; //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body $mail-&gt;msgHTML($msg); //send the message $mail-&gt;send(); //send silent notice that mail was sent $_SESSION['sent']= '1'; if($_SERVER['HTTP_REFERER']) header('Location: '.$_SERVER['HTTP_REFERER']); unset($_SESSION['post']); unset($_SESSION['err']); exit; } // if there are errors by user filling the form else { if($_SERVER['HTTP_REFERER']) header('Location: '.$_SERVER['HTTP_REFERER']); exit; } function checkLen($str,$len=2) { return isset($_POST[$str]) &amp;&amp; mb_strlen(strip_tags($_POST[$str]),"utf-8") &gt; $len; } function checkEmail($str) { return preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $str); } ?&gt; </code></pre> <p>I honestly do not know what causes, the issue, could be it is only my Firefox though i doubt it. Cheers and Thanks in advance.</p> </div>

保存表单数据

<div class="post-text" itemprop="text"> <p>I've been having some issues with this. All I want to do is save whatever the user types into the text input when they click submit even on refresh of page.</p> <p>I have already tried localStorage, but that won't work because I want it to work with any browser. As in I can save the data on chrome, and go to IE and see that the form input values are still the same.</p> <p>I have tried sending the form data via action POST, but how can I get that to KEEP the data after refresh? Right now I have it so it sends the data to a new page (that looks exactly the same) and can post the saved values in the input, but it doesn't stay there on refresh.</p> <p>I also tried something called "sisyphus" but I couldn't even get that to work even though I already have jQuery installed. I used the exact example someone gave me, so if anyone can tell me why that didn't work, this might be the best solution.</p> <p>Please help!</p> </div>

使用golang http库提交表单

<div class="post-text" itemprop="text"> <p>Oke, I'm currently trying to login in to my school website, with my own Crawler. Altough they have some protection against login. First I do a Get request to the Website so I get the token from the hidden Input field. That token I use in my next Post request to login to the url! But for some reason the http response is that I cannot resubmit the form. But with doing the same in Postman rest client (chrome plugin) I can login!</p> <p>When I try to submit a form to this url:</p> <pre><code>postLoginUrl = "?username=%s&amp;password=%s&amp;submit=inloggen&amp;_eventId=submit&amp;credentialsType=ldap&amp;lt=%s" loginUrl = "https://login.hro.nl/v1/login" </code></pre> <p>where %s are filled in credentials</p> <pre><code>req, err := client.Post(loginUrl, "application/x-www-form-urlencoded", strings.NewReader(uri)) </code></pre> <p>I'm getting as response that the Form cannot be resubmitted.</p> <p>But when I try it with Postman rest client, I'm allowed to login.</p> <p>code for Csrf token:</p> <pre><code>func getCSRFtoken() (key string) { doc, err := goquery.NewDocument(loginUrl) if err != nil { log.Fatal(err) } types := doc.Find("input") for node := range types.Nodes { singlething := types.Eq(node) hidden_input, _ := singlething.Attr("type") if hidden_input == "hidden" { key, _ := singlething.Attr("value") return key } } return "" } </code></pre> <blockquote> <p><code>goquery.NewDocument</code> is a http.Get()</p> </blockquote> <p>My question now is, how does the URL get's formatted from the library</p> </div>

如何从chrome扩展名向php sql数据库提交表单数据

<div class="post-text" itemprop="text"> <p>I don't know whats wrong with this code but it is not working. I changed form method to post and get but nothing worked. I want to submit this form to DB.</p> <p><code>popup.html:</code></p> <pre><code>&lt;form id='myForm' action='savenewfeed.php' method="get"&gt; URL: &lt;input class= 'vals' type="text" name="feed" id="url"&gt; &lt;br&gt; Title : &lt;input class= 'vals' type="text" name="title" id="title"&gt; &lt;br&gt; Channel: &lt;select class= 'vals' name='pid'&gt; &lt;option value="2"&gt;Big&lt;/option&gt; &lt;option value="3"&gt;H&lt;/option&gt; &lt;option value="4"&gt;T&lt;/option&gt; &lt;/select&gt; &lt;button id='sbmt'&gt;Submit&lt;/button&gt; &lt;/form&gt; </code></pre> <p><code>manifest:</code></p> <pre><code>{ "manifest_version": 2, "name": "One-click Kittens", "description": "This extension gets current url of browser", "version": "1.0", "permissions": [ "tabs", "cookies", "http://*/*", "http://*/", "https://*/*" ], "browser_action": { "default_icon": "icon.png", "default_popup": "popup.html" } } </code></pre> <p>popup.js:</p> <pre><code>function myAlert(){ document.getElementById('myForm').submit(); } document.addEventListener('DOMContentLoaded', function () { document.getElementById('sbmt').addEventListener('click', myAlert); }); </code></pre> <p>when i click the button, my php code appears in chrome extension, whereas , that php code to submit data works perfectly in simple web app.</p> </div>

通过php://输入原始POST,内容类型为multipart / form-data的表单无法正常工作

<div class="post-text" itemprop="text"> <p>We have a proxy PHP script and access POST form data via</p> <pre><code>$postPayload = file_get_contents('php://input'); </code></pre> <p>which usually works.</p> <p>(The reason to not use <code>$_POST</code> is that we sometimes have duplicate form input names which PHP suppresses)</p> <p>Now we have a form with</p> <pre><code>&lt;form name="form" method="post" action="/script.php" enctype="multipart/form-data"&gt; </code></pre> <p>In this case <code>file_get_contents('php://input');</code> returns an empty string.</p> <p>It can be reproduced with</p> <pre><code>curl 'http://localhost/script.php' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Referer: http://localhost/script.php?commandCode=NO_AUTH_REGIST_OPEN_USER&amp;amp;lang=de' -H 'Origin: http://misumi-europe.com.orange.imi.local' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36' -H 'Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryk3IVneARm3kqJ0fs' --data-binary $'------WebKitFormBoundaryk3IVneARm3kqJ0fs Content-Disposition: form-data; name="commandCode" NO_AUTH_NEXT ------WebKitFormBoundaryk3IVneARm3kqJ0fs ' --compressed </code></pre> <p>How can I access the RAW POST data in this case?</p> </div>

使用Ajax获取表单数据

<div class="post-text" itemprop="text"> <p>I want to get form data using ajax but I can't get the values.</p> <p>I have this javascript code to call the ajax function :</p> <pre><code>$( "#form_scenario_eco" ).submit(function( event ) { event.preventDefault(); //Pour éviter que la page se reload var formData = ($('#form_scenario_eco').serializeArray()); $.post("/kohana-v3.3.5/ajax/nouveau_scenario_eco",{scenario_eco : formData}, function(data){ alert(data); }, 'json'); }); </code></pre> <p>In my ajax file, I get the form data with :</p> <pre><code> $scenario = $_POST['scenario_eco']; </code></pre> <p>With Chrome, I have an error 500 (Internal Server Error) because I can't get the <code>$_POST['scenario_eco']</code>. </p> <p>Can someone tell me how should I get these data please ?</p> </div>

通过XMLHttpRequest表单提交

<div class="post-text" itemprop="text"> <p>I want to use XMLHttpRequest, to get the remote PHP file's response and display it on my page.</p> <p>My problem, of course: The form's data isn't being submitted to that remote PHP page.</p> <p>How do I make that happen? Thanks.</p> <pre><code>&lt;form name="creation" action="" method="post"&gt; E-mail: &lt;input required type="text" name="emailCreation" onchange="emailValidate();" onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"&gt; &lt;span id="emailRegexJavascriptResponse"&gt;&lt;/span&gt; &lt;br&gt; Username: &lt;input required type="text" name="userCreation" onchange="userValidate();" onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"&gt; &lt;span id="userRegexJavascriptResponse"&gt;&lt;/span&gt; &lt;br&gt; Password: &lt;input required type="text" name="passwordCreation" onchange="passwordValidate();" onkeypress="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();"&gt; &lt;span id="passwordJavascriptResponse"&gt;&lt;/span&gt; &lt;br&gt; &lt;input type="button" value="Submit" onclick="creationResult();"&gt; &lt;div id="here"&gt;&lt;/div&gt;&lt;div id="here2"&gt;&lt;/div&gt; &lt;!-- End --&gt; &lt;script type="text/javascript"&gt; function creationResult() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { document.getElementById("here").innerHTML=xmlhttp.responseText; } } xmlhttp.open("POST","accountcreation.php",true); xmlhttp.send(); } </code></pre> </div>

用户获取请求后,POST表单不起作用

<div class="post-text" itemprop="text"> <p>I've a problem with my admin web page, wicth doesn't work when i need to do an user's update. That is my main page, where the page should show user's details on selection form: </p> <pre><code>&lt;?php if(isset($_POST['submit'])) { session_start(); $data = $_SESSION['data']; unset($_GET['data']); header("location: modify.php"); } ?&gt; &lt;html&gt; &lt;head&gt; &lt;script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'&gt; function showUser(str) { if (str == "") { document.getElementById("txtHint").innerHTML = ""; return; } else { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (this.readyState == 4 &amp;&amp; this.status == 200) { document.getElementById("txtHint").innerHTML = this.responseText; } }; xmlhttp.open("GET","getuser.php?q="+str,true); xmlhttp.send(); } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="" method="post"&gt; &lt;select name="users" onchange="showUser(this.value)"&gt; &lt;option value=""&gt;Select a person:&lt;/option&gt; &lt;?php require_once('../conf.php'); $query_list = "SELECT * FROM studentinfo ORDER BY(id) DESC"; $result_list = mysql_query($query_list) or die('error in query_list'); // $n=1; while($row = mysql_fetch_array($result_list)) { ?&gt; &lt;option value="&lt;?php echo $row[0]; ?&gt;"&gt;&lt;?php echo $row[2]; ?&gt;&lt;/option&gt; &lt;?php // $n=$n+1; } ?&gt; &lt;/select&gt; &lt;input type="submit" name="submit"/&gt; &lt;/form&gt; &lt;br&gt; &lt;div id="txtHint"&gt; &lt;b&gt;listed here...&lt;/b&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>there is my getuser.php page:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style&gt; table { width: 100%; border-collapse: collapse; } table, td, th { border: 1px solid black; padding: 5px; } th {text-align: left;} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;?php require_once('../conf.php'); session_start(); $q = intval($_GET['q']); $getuser="SELECT * FROM studentinfo WHERE id = '".$q."'"; $result = mysql_query($getuser) or die('error in getuser'); echo "&lt;table&gt;"; ?&gt; &lt;tr&gt; &lt;th&gt;Id&lt;/th&gt; &lt;th&gt;Mac&lt;/th&gt; &lt;th&gt;Firstname&lt;/th&gt; &lt;th&gt;Lastname&lt;/th&gt; &lt;th&gt;Email&lt;/th&gt; &lt;th&gt;Department&lt;/th&gt; &lt;th&gt;City&lt;/th&gt; &lt;th&gt;State&lt;/th&gt; &lt;/tr&gt; &lt;?php if($row = mysql_fetch_array($result)) { $_SESSION['data'] = $row; echo "&lt;tr&gt;"; echo "&lt;td&gt;" . $row[0] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row[1] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row[2] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row[3] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row[4] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row[5] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row[6] . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row[7] . "&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>at the end my modify.php page:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style&gt; table { width: 100%; border-collapse: collapse; } table, td, th { border: 1px solid black; padding: 5px; } th {text-align: left;} &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;?php require_once('../conf.php'); session_start(); $data = $_SESSION['data']; //clear get data if(isset($_POST['submitbutton'])) { echo "11111111"; $edit="UPDATE TABLE studentinfo SET id=$data[0], mac='$_POST['Mac']', firstname='$_POST['FirstName']', lastname='$_POST['LastName']', email='$_POST['Email']', department='$_POST['Department']', city='$_POST['City']', state='$_POST['State']' WHERE id=$data[0]"; $result_edit=mysql_query($edit) or die ('edit user failed'); if(!$result_edit) echo "edit done"; else echo "edit failed"; } //if(ISSET($_POST['submit'])) ?&gt; &lt;form action="" type="post"&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;Mac&lt;/th&gt; &lt;th&gt;FirstName&lt;/th&gt; &lt;th&gt;LastName&lt;/th&gt; &lt;th&gt;Email&lt;/th&gt; &lt;th&gt;Department&lt;/th&gt; &lt;th&gt;City&lt;/th&gt; &lt;th&gt;State&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;input type="text" name="Mac" value="prova"&gt;&lt;/input&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="text" name="FirstName" value="&lt;?php echo htmlspecialchars($data['firstname']); ?&gt;" /&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="text" name="LastName" value="&lt;?php echo $data[3]; ?&gt;" /&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="text" name="Email" value="&lt;?php echo $data[4]; ?&gt;" /&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="text" name="Department" value="&lt;?php echo $data[5]; ?&gt;" /&gt;&lt;/td&gt; &lt;td&gt; &lt;input type="text" name="City" value="&lt;?php echo $data[6]; ?&gt;" /&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="text" name="State" value="&lt;?php echo $data[7]; ?&gt;" /&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="submit" name="submitbutton" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Now, it looks to work well until the modify page. i can't understand why in modify.php page i can't save variable on POST for the mysql upload. can someone help my to understant why don't work pls. Thanks.</p> </div>

HTML表单不会在IE或Firefox中提交

<div class="post-text" itemprop="text"> <p>I'm having a strange issue with my HTML (or PHP) code on my web site. I'm pretty new to HTML and PHP (I'm more .NET).</p> <p>On all forms on my website, the forms fail to submit in IE or Firefox. However, they work absolutely fine in Chrome (all platforms) and Safari (only tested on iPad/iPhone).</p> <p>I could post the code if required, however, the issue is on my live website. Here are the forms which are immediately accessible via the homepage which have the same issue.</p> <p><a href="https://trentdiscos.co.uk/contact.php" rel="nofollow">https://trentdiscos.co.uk/contact.php</a></p> <p><a href="https://trentdiscos.co.uk/login.php" rel="nofollow">https://trentdiscos.co.uk/login.php</a></p> <p>All you have to do is click the submit button without entering any data. You should get an error message when the form is submitted which is returned using some simple PHP code.</p> <p>If the full PHP code helps then I'm happy to post it. However, it appears to be a posting issue to me.</p> <p>I can also replicate this issue on a local Apache web server.</p> <p>Can anyone help please?</p> </div>

HTML表单显示代码而不是PHP输出

<div class="post-text" itemprop="text"> <p>I've been trying to implement this form into my HTML (Bootstrap 4 alpha) website, but I can't get it working properly. </p> <p>Let's start with the goals:</p> <ol> <li>A working form that checks if valid input is given for all fields before it sends an email.</li> <li>If the user didn't enter a valid input for one or more of the fields, an error message should appear on the page itself (so no redirect to an error page).</li> <li>preferably, when the user made a mistake with one of the input fields and the error shows up, the previously entered data shall remain in the fields.</li> </ol> <p>I found some useful help somewhere on the internet, a PHP and HTML of which I could use the stuff I needed. However, this form doesn't work, even when I upload the original code without changing anything. </p> <p>I thought PHP might not be supported by the server I was uploading it to, but it is and I even got a form working that would just take the input and send it to the receiver with no questions asked. </p> <p><strong>What I didn't get to work though was to echo an output of my PHP file in my HTML. What am I doing wrong?</strong></p> <p>HTML:</p> <pre><code>&lt;form action="php/mail.php" role="form" method="post" class=""&gt; &lt;div class="form-group"&gt; &lt;label for="name" class="col-sm-2 control-label sr-only"&gt;Naam&lt;/label&gt; &lt;input type="text" class="form-control form-control-sm form" id="name" name="name" placeholder="Name" value="&lt;?php echo htmlspecialchars($_POST['name']); ?&gt;"&gt; &lt;?php echo "&lt;p class='text-danger'&gt;$errName&lt;/p&gt;";?&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="email" class="col-sm-2 control-label sr-only"&gt;Email&lt;/label&gt; &lt;input type="email" class="form-control form-control-sm form" id="email" name="email" placeholder="your.name@example.com" value="&lt;?php echo htmlspecialchars($_POST['email']); ?&gt;"&gt; &lt;?php echo "&lt;p class='text-danger'&gt;$errEmail&lt;/p&gt;";?&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="message" class="col-sm-2 control-label sr-only"&gt;Message&lt;/label&gt; &lt;textarea class="form-control form-control-sm form" rows="4" name="message" placeholder="My Message..."&gt;&lt;?php echo htmlspecialchars($_POST['message']);?&gt;&lt;/textarea&gt; &lt;?php echo "&lt;p class='text-danger'&gt;$errMessage&lt;/p&gt;";?&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="human" class="col-sm-2 control-label sr-only"&gt;2 + 3 = ?&lt;/label&gt; &lt;input type="text" class="form-control form-control-sm form" id="human" name="human" placeholder="2 + 3 = ?"&gt; &lt;?php echo "&lt;p class='text-danger'&gt;$errHuman&lt;/p&gt;";?&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary btn-sm"&gt; &lt;input type="reset" value="Clear" class="btn btn-primary btn-sm"&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;?php echo $result; ?&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>PHP:</p> <pre><code>&lt;?php if (isset($_POST["submit"])) { $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $human = intval($_POST['human']); $from = 'Demo Contact Form'; $to = 'test@testmail.com'; $subject = 'Message from Contact Demo '; $body = "From: $name E-Mail: $email Message: $message"; // Check if name has been entered if (!$_POST['name']) { $errName = 'Please enter your name'; } // Check if email has been entered and is valid if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { $errEmail = 'Please enter a valid email address'; } //Check if message has been entered if (!$_POST['message']) { $errMessage = 'Please enter your message'; } //Check if simple anti-bot test is correct if ($human !== 5) { $errHuman = 'Your anti-spam is incorrect'; } // If there are no errors, send the email if (!$errName &amp;&amp; !$errEmail &amp;&amp; !$errMessage &amp;&amp; !$errHuman) { if (mail ($to, $subject, $body, $from)) { $result='&lt;div class="alert alert-success"&gt;Thank You! I will be in touch&lt;/div&gt;'; } else { $result='&lt;div class="alert alert-danger"&gt;Sorry there was an error sending your message. Please try again later&lt;/div&gt;'; } } } ?&gt; </code></pre> <p>The results I get from this are like this:</p> <p><img src="https://i.stack.imgur.com/q95Vc.jpg" alt="Screenshot"></p> <p>Seems to me that the HTML file doesn't execute the PHP code, instead just displays raw code. I tried both saving the HTML as .html and as .php, both gave different but false results.</p> </div>

PHP表单适用于IE,但不适用于Chrome或Firefox

<div class="post-text" itemprop="text"> <p>Okay so fairly straight forward php contact form. It submits and sends the data in ie and takes the user to a thank you page. However in both google chrome and firefox, my users are taken to the thank you page but their form data is not sent to the email.<br> This is the code I am using:<br> <strong>Form Data on one page</strong><br></p> <pre><code>&lt;table width="400" border="0" align="center" cellpadding="0" cellspacing="1"&gt; &lt;tr&gt; &lt;td&gt;&lt;form name="form1" method="post" action="send_wl.php"&gt; &lt;table width="100%" border="0" cellspacing="1" cellpadding="3"&gt; &lt;tr&gt; &lt;td width="16%"&gt;First Name&lt;/td&gt; &lt;td width="2%"&gt;:&lt;/td&gt; &lt;td width="82%"&gt;&lt;input name="name" type="text" id="name" size="50"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;tr&gt; &lt;td width="16%"&gt;Last Name&lt;/td&gt; &lt;td width="2%"&gt;:&lt;/td&gt; &lt;td width="82%"&gt;&lt;input name="lastname" type="text" id="lastname" size="50"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Address&lt;/td&gt; &lt;td&gt;:&lt;/td&gt; &lt;td&gt;&lt;textarea name="address" cols="50" rows="4" id="address"&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Date of Birth&lt;/td&gt; &lt;td&gt;:&lt;/td&gt; &lt;td&gt;&lt;input name="dob" type="date" id="dob" size="50"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Health Care Number&lt;/td&gt; &lt;td&gt;:&lt;/td&gt; &lt;td&gt;&lt;input name="phn" type="text" id="phn" size="50"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Phone&lt;/td&gt; &lt;td&gt;:&lt;/td&gt; &lt;td&gt;&lt;input name="ac" type="text" id="ac" size="3"&gt;&lt;input name="phone" type="text" id="phone" size="7"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Email&lt;/td&gt; &lt;td&gt;:&lt;/td&gt; &lt;td&gt;&lt;input name="email" type="text" id="email" size="50"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Comments&lt;/td&gt; &lt;td&gt;:&lt;/td&gt; &lt;td&gt;&lt;textarea name="comment" cols="50" rows="4" id="comment"&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&lt;input type="submit" name="Submit" value="Submit"&gt; &lt;input type="reset" name="Submit2" value="Reset"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; </code></pre> <p><strong>php script on another pages "send_wl.php"</strong></p> <pre><code>&lt;?php $to = "ouremail@gmail.com"; $from = $_POST['email'] ; $name = $_POST['name'] ; $headers = "From: $from"; $subject = "New Patient Data"; $fields = array(); $fields["name"] = "name"; $fields["lastname"} = "lastname"; $fields["address"] = "address"; $fields["email"] = "email"; $fields["ac"] = "ac"; $fields["phone"] = "phone"; $fields["dob"] = "dob"; $fields["phn"] = "phn"; $fields["comment"] = "comment"; $body = "We have received the following information: "; foreach($fields as $a =&gt; $b){ $body .= sprintf("%20s: %s ",$b,$_REQUEST[$a]); } $headers2 = "From: noreply@ourwebsite.com"; $subject2 = "Thank you for contacting us"; $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.ourwebsite.com"; if($from == '') {print "You have not entered an email, please go back and try again"; } else { if($name == '') {print "You have not entered a name, please go back and try again"; } else { $send = mail($to, $subject, $body, $headers); } if($send) {header( "Location: http://www.thewebsite.com/thankyou.html" );} else {print "We encountered an error sending your mail, please notify mailreciepient@gmail.com"; } } } ?&gt; </code></pre> <p>I have made all the suggested changes to the web site as well and this form is still not working. </p> <p>Should I also be removing the = "lastname" from the $fields["lastname"] = "lastname" I know it seems like a stupid question but I am honestly pulling my hair out on this one.</p> </div>

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

ArrayList源码分析(入门篇)

ArrayList源码分析 前言: 写这篇博客的主要原因是,在我上一次参加千牵科技Java实习生面试时,有被面试官问到ArrayList为什么查找的速度较快,插入和删除的速度较慢?当时我回答得不好,很大的一部分原因是因为我没有阅读过ArrayList源码,虽然最后收到Offer了,但我拒绝了,打算寒假学得再深入些再广泛些,下学期开学后再去投递其他更好的公司。为了更加深入理解ArrayList,也为

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

String s = new String(" a ") 到底产生几个对象?

老生常谈的一个梗,到2020了还在争论,你们一天天的,哎哎哎,我不是针对你一个,我是说在座的各位都是人才! 上图红色的这3个箭头,对于通过new产生一个字符串(”宜春”)时,会先去常量池中查找是否已经有了”宜春”对象,如果没有则在常量池中创建一个此字符串对象,然后堆中再创建一个常量池中此”宜春”对象的拷贝对象。 也就是说准确答案是产生了一个或两个对象,如果常量池中原来没有 ”宜春” ,就是两个。...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

玩转springboot启动banner定义所得

最近接手了一个springboot项目,不是不熟悉这个框架,启动时打印的信息吸引了我。 这不是我熟悉的常用springboot的打印信息啊,我打开自己的项目: 还真是的,不用默认的感觉也挺高大上的。一时兴起,就去研究了一下源代码,还正是有些收获,稍后我会总结一下。正常情况下做为一个老程序员,是不会对这种小儿科感兴趣的,不就是一个控制台打印嘛。哈哈! 于是出于最初的好奇,研究了项目的源代码。看到

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

你打算用Java 8一辈子都不打算升级到Java 14,真香

我们程序员应该抱着尝鲜、猎奇的心态,否则就容易固步自封,技术停滞不前。

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

立即提问
相关内容推荐