是否有一种很好的方法来检查表单输入使用正则表达式,以确保它是一个正确的样式电子邮件地址?自昨晚以来一直在搜索,如果这是一个子网站的电子邮件地址,那么回答人们关于这个主题的问题的每个人似乎都有问题.
有没有把一个javascript字符串传递给NodeJS友好的MySQL?我正在尝试将电子邮件地址传递给我的NodeJS服务器并查询到MySQL数据库.使用常用文本(如用户名)工作正常时,但电子邮件地址却没有.明确地使用转义不是正确的答案,因为它不适用于SQL插入.我假设我需要PHP函数的一些东西mysql_real_escape_string().
我正在尝试使用PHP从MySQL数据库中搜索两个字段.
例如
mysql_query("
SELECT (first_name,last_name) As name
FROM people
WHERE (name LIKE '%" . $term . "%')
");
Run Code Online (Sandbox Code Playgroud)
我认为这是使用的代码,但无济于事.我做了这个已经有一段时间了,我不记得究竟如何达到预期的效果.
我试图发布到我的Tornado Web服务器,但一直收到405错误.不确定出了什么问题.我是python的新手,但我一直在寻找这个约一个月,最后决定试一试.
龙卷风Web服务器:
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
import os
import string
from time import sleep
from datetime import datetime
import hashlib
import json
from tornado.options import define, options
define("port", default=8001, help="run on the given port", type=int)
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
class LoginHandler(tornado.web.RequestHandler):
def get(self):
email_address = self.get_argument('email')
password = self.get_argument('password')
if email_address == '':
login_response = "{'error': true, 'msg': 'Please enter your email address.'}"
elif password == '':
login_response …Run Code Online (Sandbox Code Playgroud) 在我的登录脚本中,它为用户登录其电子邮件地址和密码创建一个 cookie。我遇到的问题是,当设置电子邮件地址时,它将整个电子邮件地址放在双引号之间。我怎样才能让它不呢?
if request.method == 'POST':
post = request.POST
email = post.get('email', None)
response.set_cookie('emailaddress', email, max_age=expire_v)
Run Code Online (Sandbox Code Playgroud) 我正在为客户端开发一个API脚本,并且他们需要一个服务来获取内容长度.据我所知,PHP无法在标头中发送Content-Length.我可能错了,但没有它,我会继续Premature end of data in tag html line 3 [string:Exception:private] => [code:protected] => 0 [file:protected] =>
代码如下:
<?
try
{
$soap_url = 'http://admin.stock.imdfulfilment.com/api/service.asmx';
$client = new SoapClient($soap_url);
$header = new SoapHeader(
'http://admin.stock.imdfulfilment.com/api/service/',
'GetCouriers',
array(
'Content-Length' => '255'
)
);
$client->__setSoapHeaders($header);
var_dump($client->__getFunctions());
}
catch (Exception $e)
{
print_r($e);
}
Run Code Online (Sandbox Code Playgroud) 因此使用带有输入的区域应该添加结果,它可以工作,但之后它也会刷新页面.
var targetX, targetY;
var tagCount = 0;
$(function(){
$('#tag').live('click', function(){
var iid = $(this).attr('p');
var img = $('#img-'+iid);
$(img).wrap('<div id="tag-wrapper"></div>');
$('#tag-wrapper').css({width: $(img).outerWidth(), height: $(img).outerHeight()});
$('#tag-wrapper').append('<div id="tag-target"></div><div id="tag-input">Name<input type="text" id="tag-name"><span id="savetag">Save</span> <span id="canceltag">Cancel</span></div>');
$(img).click(function(e){
mouseX = e.pageX - $('#tag-wrapper').offset().left;
mouseY = e.pageY - $('#tag-wrapper').offset().top;
targetWidth = $('#tag-target').outerWidth();
targetHeight = $('#tag-target').outerHeight();
targetX = mouseX - targetWidth/2;
targetY = mouseY - targetHeight/2;
inputX = mouseX + targetWidth/2;
inputY = mouseY + targetHeight/2;
if($('#tag-target').css('display')=='block'){
$("#tag-target").animate({left: targetX, top: targetY}, 500);
$("#tag-input").animate({left: inputX, top: inputY}, …Run Code Online (Sandbox Code Playgroud) 我试图将PHP脚本的结果循环到我的jquery好友列表中.似乎无法让列表显示任何但未定义的内容,但是如果我将它附加到正文中它只显示数组的最后一个.我的代码是......
$(function() {
$('<div />').html('<div id="buddies" class="buddies" style="vertical-align:bottom"><div class="imheader"> Online Favorites<span class="fr"><a href="#" id="exitlist">X</a></span></div><div class="imheader2"><div class="imheaderspan"><a href="#">Options</a></div></div><ul class="imwindow"><div id="myonlinefavs">' + FL() + '</div></ul></div><div id="chatbar" class="chatbar"><div id="ims"></div><div class="buddylist" id="buddylist"><center><a href="#" id="im-menu" class="im-menu">Favorites (<strong id="friendsonline">0</strong>)</a></center></div></div>').appendTo('body');
var imRoot = $("#im-menu");
var buddies = $("#buddies");
imRoot.click(function(){
buddies.toggle();
imRoot.blur();
return( false );
});
$("#exitlist").click(function(){
buddies.toggle();
imRoot.blur();
return( false );
});
$(document).click(function( event ){
if (buddies.is( ":visible" ) && !$( event.target ).closest( "#buddies" ).size()){
buddies.hide();
}
});
function FL(){
$.ajax({
type: 'POST',
url: 'config/receive_buddylist.php',
cache: 'false',
dataType: …Run Code Online (Sandbox Code Playgroud) 我使用Apache/PHP Server和Django中的表单来处理我的所有帖子/请求.如何设置它以便不设置字段它不会导致错误?
PHP表格:
<form action="http://www.mydomain.com:8003/login/" method="post">
<input type="text" name="email" id="email"><br>
<input type="text" name="password" id="password"><br>
<input type="checkbox" name="remember"><br>
<input type="submit" value="send" id="send">
</form>
Run Code Online (Sandbox Code Playgroud)
Django的:
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def index(request):
if request.method == 'POST':
post = request.POST
email = post['email']
pass = post['password']
remember = post['remember']
if remember:
expire_v = 30
else:
expire_v = None
response = HttpResponse(email)
response.set_cookie('emailaddress', email, max_age=expire_v)
response.set_cookie('password', pass, max_age=expire_v)
return response
Run Code Online (Sandbox Code Playgroud)
问题是如果没有检查记住它会导致错误.