Share Improve This Question: Can I Link This PHP File To The Other One?" ?
Share Improve This Question: Can I Link This PHP File To The Other One?" ?
<?php
else
die("Please enter a username and password");
?>
I believe this code is now connected to my other page (http://jsfiddle.net/6yw8a2ue/) It shows
some errors next to the fields in browser: "Notice: Undefined indiex: Username in
G:\xampp\htdocs\Sportsday\entryformlongon.php"...
and once i enter a username and password it goes through to blank page with the error:
"Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the
future: use mysqli or PDO instead in G:\xampp\htdocs\Sportsday\login.php on line 11"
phphtmlcssxampp
Charley Baker
4711 gold badge11 silver badge55 bronze badges
2
This if ($username&&£$password) - remove the £ - if ($username &&
$password) that's where the parse error originates from. Now, what do you mean by "How
can I link this php file to the other one?" ? – Funk Forty Niner Oct 23 '14 at 17:39
well i was following a log in tutorial (youtube.com/watch?v=y7ae_cZahPs) and they used two
separate php files and it connected fine. but for me its not – Charley Baker Oct 23 '14 at 17:45
@Fred-ii- i need the code show in the screenshot to be used for my log in page
basically – Charley Baker Oct 23 '14 at 17:45
So, why not show us what you're using then, or is that your entire code? – Funk Forty Niner Oct
23 '14 at 17:45
1
You have completely changed the original question so that nearly all the answers you have
received are no longer relevant (as @Fred-ii- pointed out). If you have a different question
you need to ask a new question rather than updating this one to the point of being
unrecognizable from what was originally asked which was how to include the files
correctly. – Ian Oct 24 '14 at 5:16
show 9 more comments
7 Answers
Active OldestVotes
1
Please look over this documentation. http://php.net/manual/en/function.require-once.php
iamcutler
3111 silver badge11 bronze badge
add a comment
0
point your form action atribute to the php file.
danielson317
2,58422 gold badges1818 silver badges3434 bronze badges
add a comment
0
Require at the top of the page to be included. require 'filename';
http://www.w3schools.com/php/php_includes.asp
share improve this answer follow
answered Oct 23 '14 at 17:46
Mark Hulbrock
10155 bronze badges
add a comment
0
header('Location: http://www.example.com/');
exit;
I assume by link to other php file, you mean forward to another page once complete.
share improve this answer follow
answered Oct 23 '14 at 17:47
Adrian Stride
5966 bronze badges
add a comment
0
There are 4 options to include the file into the main document.
include
include_once
require
require_once
include doc, include_once doc, require doc, require_once doc
Each of these will add the code to your main file and do essentially the same
thing. include and require will include the file as many times as the line of code is called
(which can cause issues if you just need it called once). include_once and require_once will
import the file to the document only one time regardless of whether or not that line of code is
called multiple times.
So if you have form.php and want to include it it would look something like this for each option.
include 'form.php';
include_once 'form.php';
require 'form.php';
require_once 'form.php';
Depending on where the document lies that you are trying to include you will need to get the
correct directory first (ie if you are trying to include from from /path/file.php from
/path/path/file.php). Unlike normal HTML '/'does not result in your site root. It results in your
server root.
So if you have a file that exists at website.com/path/file.php you couldn't just do include
'/path/file.php' because that would actually look for the file at the root of the server which would
not exist.
To get around this you will want to utilize $_SERVER['DOCUMENT_ROOT'] which will then grab the
root of your document from the server which might look something like the following (depending
on your setup):
/var/www/html/website.com
And so rather than having to figure that out, you can just add the document root line to the
include statements
Ian
2,78044 gold badges2525 silver badges3535 bronze badges
I have edited the original question – Charley Baker Oct 23 '14 at 18:03
add a comment
0
You can redirect to other page when fields are empty or inputs are not matching.Can simply do
$username=$row["username"];
$password=$row["password"];
header("location:page_to_link.php?u=".$username);
}
else{
header("location:page you want to redirect");
}
you have to start session on the page you redirecting(linking) them by session_start().
Salim Khan
5311 silver badge1212 bronze badges
I have edited the original question, im looking for something else – Charley Baker Oct 23 '14 at
18:04
add a comment
0
You have forgotten to check if the form is submitted add the floowing in the beginning of your
code:
and off course, don't forget to place a close bracket at the end
share improve this answer follow
answered Oct 23 '14 at 18:34
jsp
1
add a comment
Not the answer you're looking for? Browse other questions tagged php html css xampp or ask
your own question.