/    Sign up×
Community /Pin to ProfileBookmark

Can I have requre_once & cookie together

I have developed one in which I tried to have require_once and cookie . but I got error of header . So is is possible to have both in one file

[code=php]
/ require_once(‘include/connect.php’);
if ($_POST[‘submit’]) {
//***** This is the code I had in connect.php which I move to main file

$hostUrl = ‘localhost’;
$username = ‘root’;
$password = ”;
//****************************************

$connectID = mysql_connect ($hostUrl, $username , $password)
or die (“Unable to connect to the Server”);

$username = $_POST[‘UNAME’];
$password_t = $_POST[‘PASSWORD1’];

//Establishing the connection to the table
mysql_select_db (“ticketing”, $connectID) or
die (“Unable to Fetch Record(s) From the Database”);
//Selecting record(s) based on the parameters passed

$result = mysql_query(“SELECT * FROM userinfo WHERE Uname = ‘$username’ AND Password = ‘$password_t'”,$connectID)
or die (“Unable to Authenticate the User “);
$num_rows = mysql_num_rows($result);

if ($num_rows >0 )
{
$AD_PERM = false; //This is Admin Permission
$FC_PERM = false; //Full Permission given
$ans = mysql_fetch_array($result, MYSQL_ASSOC);
if ($ans[‘Admin_AC’] == true) {
$AD_PERM= true;
$FC_PERM = false;
setcookie (“Admin”);
header (‘Location:recp.php’);
}
if ($ans[‘Full_AC’] == true) {
$AD_PERM = false;
$FC_PERM = true;
setcookie(“Full”);
}

}
if($num_rows < 1)
{
?>

<style>
a:hover {background: #836FFF ;color:#FFFF00; text-decoration:none}
</style>
<table>
<tr>
<td width = “400”> </td>
<td>
<table>
<tr>
<td style = “font:verdana; font-size:125%”>Invalid Login Credentials ..!! </td>
</tr>
<tr>
<td> <a href = “Main.html”>Click to Retun to Login Page… </a></td>
</tr>
</table>
</td></tr>
</table>
<?php

}
}

?>

[/code]

Can you guide me.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 28.2008 — There is no reason you cannot have both in a script. The code you have presented here is invalid, with the "/" before the require_once(), but I suspect that's just a copy-and-paste error? If so, we probably need more info to determine what the problem is, including the symptoms you are seeing that caused you to ask the question in the first place.
Copy linkTweet thisAlerts:
@arpit_vavadiaauthorDec 28.2008 — Even if you remove the "/" from to require_one it woud not work ,
Copy linkTweet thisAlerts:
@NogDogDec 28.2008 — Define "would not work". Do you get an error message of some sort? If so, what is it? If not, have you checked the error logs or tried turning on all error reporting?

Remember that nothing can be output before the call to setcookie(). This output includes HTML text not within <?php...?> tags, error messages output by PHP, newlines or unicode BOM characters before the opening <?php tag, etc.
×

Success!

Help @arpit_vavadia spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...