我正在建立一个包含登录页面的网站.我需要在用户成功登录后将用户重定向到他们的个人资料页面,但我不知道如何在PHP中这样做(这是我的第一个网站).
我已经搜索过互联网,并且被告知header()函数应该可以解决问题,但只有在使用之前我没有输出任何信息时它才会起作用.
那就是问题所在.我输出了一堆信息(包括HTML来构建登录页面本身).
那么如何将用户从一个页面重定向到另一个页面呢?
我有什么选择?此外,这些情况下的最佳做法是什么?
编辑:这是我的整个login.php页面
<?php
session_start();
echo "<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Sprout</title>
<link rel='stylesheet' href='stylesheet.css' type='text/css'>
</head>
<body>
<div class='box'>
<form action='login.php' method='post'>
Name<br /> <input type='text' name='username' class='form'/><br />
Password<br /> <input type='password' name='password' class='form'/>
<input type='submit' value='Login' class='button' />
</form>
</div>
</body>
</html>";
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$username = $_POST["username"];
$password = $_POST["password"];
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "root";
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ("Error connecting to database"); …Run Code Online (Sandbox Code Playgroud) // screen.h
#ifndef screen_h
#define screen_h
#define MAC 1
#define WIN 2
#define LNX 3
#ifdef PLATFORM
# undef PLATFORM
#endif
#define PLATFORM MAC
void screen_init();
#endif
Run Code Online (Sandbox Code Playgroud)
// screen.c
#include <string.h>
#include <stdlib.h>
#include "screen.h"
#if PLATFORM == MAC
#include <curses.h>
void screen_init(){
erase();
}
#endif
Run Code Online (Sandbox Code Playgroud)
我不明白为什么它没有在screen.h中看到我的原型
任何建议/提示表示赞赏!
我将一个域重定向到另一个域,但我想保留重定向中的路径.例如,我想访问www.example.com/services/education/page.html,但我的重定向会带来它们www.new-example.com/services/education/page.html.我在.htaccess文件中写什么来保留路径"/services/education/page.html"?
现在我有:
redirect 301 http://www.example.com/ http://www.new-example.com/
Run Code Online (Sandbox Code Playgroud)
但我不确定这是否有效(在等待域名详细信息等时无法测试).我只想确定何时将网站直播.是的还是我离开基地了?
谢谢!
一些上下文:我正在阅读有关使用OpenGL 的教程.本教程需要几个库才能工作.其中一个库是FreeGLUT.我使用Lion在OS X上.
我已经下载了FreeGLUT并按照说明进行安装,但是当我运行'make all'命令时,我收到此错误:
error: GL/gl.h: No such file or directory
error: GL/glu.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)
我已经在互联网上寻找解决方案,而我能够从中理解的是,编译器在查找这些文件时遇到了问题,并且编译器正在使用的路径需要更改.
编辑:好的,我已经发现它不是编译器,它是由于某种原因那些文件不存在.试着弄清楚他们为什么不在那里.
所以,我有一个页面上有一个带有"Create"值的按钮.当我单击"创建"按钮而不填写任何字段时,它会验证表单并在同一页面上显示错误消息.当我在浏览器中这样做时,它工作正常,但当我这样做时phpunit,它有意想不到的结果,我不知道为什么.
这是我的集成测试:
public function testCreateValidation()
{
$this->visit(route('patients.indexes.create', $this->patient->id));
$this->press('Create');
$this->seePageIs(route('patients.indexes.create', $this->patient->id));
}
Run Code Online (Sandbox Code Playgroud)
这就是结果:
There was 1 failure:
1) Tests\Integration\IndexControllerTest::testCreateValidation
Did not land on expected page [http://localhost/patients/69/indexes/create].
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'http://localhost/patients/69/indexes/create'
+'http://localhost/patients'
/vagrant/vendor/laravel/framework/src/Illuminate/Foundation/Testing/InteractsWithPages.php:141
/vagrant/tests/Integration/IndexControllerTest.php:51
Run Code Online (Sandbox Code Playgroud)
我不明白为什么它被重定向到patients页面.
以下是create正在测试的Laravel 方法:
public function create($id)
{
$index = $this->indexes->newInstance();
$patient = $this->patients->findOrFail($id);
return view('patient.index.create', ['index' => $index, 'patient' => $patient]);
}
Run Code Online (Sandbox Code Playgroud)
以下是该create视图的相关部分:
<?= Form::open(['route' => array('patients.indexes.store', $patient->id), 'class' …Run Code Online (Sandbox Code Playgroud) 在页脚中排队脚本时遇到问题.
wp_deregister_script('jquery');
wp_enqueue_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js', array(), false, true);
Run Code Online (Sandbox Code Playgroud)
这是wp_enqueue_script定义:
wp_enqueue_script(
$handle
,$src
,$deps
,$ver
,$in_footer
);
Run Code Online (Sandbox Code Playgroud)
如您所见,我将$ in_footer设置为true.这对我不起作用.如果没有这个参数,它可以正常工作并将其放在header.php中.为什么它不适用于$ in_footer?
我不想使用Wordpress的内置媒体上传器.
我的网站上有一个表单(在前端),我需要允许任何人将图像上传到wp-content中的uploads文件夹.我找到了很多教程,但是他们都告诉我如何用wordpress uploader做到这一点.我需要能够验证用户上传的内容.
任何帮助是极大的赞赏!!!
谢谢.
当我只在移动触摸屏设备上时,我在我的网站上加载了jQuery Mobile.当我这样做的时候.它弄乱了一切.例如,选择菜单不能正常工作,页面底部会出现"加载,加载,未定义"字样.我知道我错过了什么,但不知道是什么.
关于我可能遗失的任何想法?
谢谢
编辑:好的,所以除了jQuery和jQuery Mobile之外,我拿出了我正在运行的所有脚本.我首先调用jQuery,然后调用jQuery Mobile.它仍然打破了网站的各个方面.
它破坏了什么: - 我无法通过导航栏导航到任何其他页面,如果我点击导航项目,并查看网址,则会显示正确的网址(其中包含#),例如:/#/ about-us /然后,它只是重定向到主页,页面变白
选择菜单有奇怪的结果.它打印出旁边的选择权中的任何内容.如果您在ipad上以横向模式并且单击选择,它会将您发送到页面底部(很奇怪).
它打印出'loading'两次,并在页面底部打印一次'undefined'
我所有的脚本都是jQuery和jQuery Mobile.我还应该提一下,我正在使用wordpress,所以它可能已经排队了一些其他脚本(我已经取消注册了Wordpress的jquery版本并将我自己排队)
其他人遇到这些问题?
好的,我的代码在下面,所以我将解释我正在做什么以及我得到的结果.
我正在尝试使用navigator.geolocation.watchPosition获取用户位置.我已经指定了成功和错误回调.我第一次得到这个位置通常是非常不准确所以我使用watchPosition继续获取位置,直到它尝试了4次或者得到一个精确到500米以内的位置.
我遇到的问题:
它永远不会进入Android的错误回调(在HTC Sensation和三星Galaxy S3上测试).然而,在iPhone上,它似乎在50%的时间内输入错误回调.
它也永远不会超时.它一直在搜索,直到它收到一个位置.
我搜索了许多论坛帖子和许多stackoverflow问题以及地理定位和其他任何文档的规范.关于它的信息不多,更不用说这些问题了.有没有我做错了?或者这只是与位置合作的本质?
if(navigator.geolocation){
var geo_count = 0;
var wpid = navigator.geolocation.watchPosition(success, error, {
enableHighAccuracy: true,
maximumAge: 0,
timeout: 10000
});
function success(position){
alert(position.coords.accuracy)
geo_count = geo_count + 1;
if(position.coords.latitude && position.coords.longitude && position.coords.accuracy < 500){
navigator.geolocation.clearWatch(wpid);
alert('position obtained!');
}
else if(geo_count > 4){
navigator.geolocation.clearWatch(wpid);
alert('inaccurate position obtained');
}
}
function error(error){
switch(error.code){
case 1:
alert('permission denied');
break;
case 2:
alert('position unavailable');
break;
case 3:
alert('timeout');
break;
default:
alert('unknown error');
break;
}
}
}
Run Code Online (Sandbox Code Playgroud) 这是我的剧本.很简单.问题在于"with_items".它遍历所有项目,但是,它只将最后一项写入crontab文件.我认为它会覆盖它.为什么会这样?
- name: Create cron jobs to send emails
cron:
name="Send emails"
state=present
special_time=daily
job="/home/testuser/deployments/{{ item }}/artisan --env={{
item }} send:healthemail"
with_items:
- london
- toronto
- vancouver
Run Code Online (Sandbox Code Playgroud)