Jump to content

$_server[php_self]


laado
 Share

Recommended Posts

when i add news then it give following errorYou don't have permission to access /news/<br /><b>Notice</b>: Use of undefined constant PHP_SELF - assumed 'PHP_SELF' in <b>C:/wamp/www/news/add_news.php</b> on line <b>44</b><br />/news/add_news.php on this server. i m new in php can anyone help this why this error comes.its urgent please reply me

Link to comment
Share on other sites

line of code is <form method ="post" action"<?php echo $_SERVER['PHP_SELF'] ?>">I change it <form method ="post" action"<? echo $_SERVER['PHP_SELF'] ?>">mean i change <?php to <? but now the error comes you r not authorized to view this pageyou might not have to view this directory or page using the credentials you supplied.now whts the problem please help me urgent.Whole code is <title>hotnews</title><?php//LAST UPDATE// 27-09-2007include("config.php"); if(isset($_POST['submit'])) {//begin of if($submit). // Set global variables to easier names $title = $_POST['title']; $text1 = $_POST['text1']; $text2 = $_POST['text2']; //check if (title) field is empty then print error message. if(!$title){ //this means If the title is really empty. echo "Error: News title is a required field. Please fill it."; exit(); //exit the script and don't do anything else. }// end of if //run the query which adds the data gathered from the form into the database $result = mysql_query("INSERT INTO news (title, dtime, text1, text2) VALUES ('$title',NOW(),'$text1','$text2')",$connect); //print success message. echo "<b>Thank you! News added Successfully!<br>You'll be redirected to Home Page after (4) Seconds"; echo "<meta http-equiv=Refresh content=4;url=index.php>"; }//end of if($submit). // If the form has not been submitted, display it!else {//begin of else ?> <br> <h3>::Add News</h3> <form method="post" action="<?php echo $_SERVER

[php_SELF] ?>"> Title: <input name="title" size="40" maxlength="255"> <br> Text1: <textarea name="text1" rows="7" cols="30"></textarea> <br> Text2: <textarea name="text2" rows="7" cols="30"></textarea> <br> <input type="submit" name="submit" value="Add News"> </form> <?php }//end of else ?>
Post the code you are using, please.Try:
echo $_SERVER['PHP_SELF'];

Notice the caps and the single quotes.

Link to comment
Share on other sites

You are better off with the full token there: <?phpAnd you still have no single quotes around the PHP_SELF.Also, please cut and paste the precise (actual) error message.

Link to comment
Share on other sites

following is a code<html> <title>hotnews</title><?phpinclude("config.php"); if(isset($_POST['submit'])) {//begin of if($submit). // Set global variables to easier names $title = mysql_escape_string($_POST['title']); $text1 = mysql_escape_string($_POST['text1']); $text2 = mysql_escape_string($_POST['text2']); //check if (title) field is empty then print error message. if(!$title){ //this means If the title is really empty. echo "Error: News title is a required field. Please fill it."; exit(); //exit the script and don't do anything else. }// end of if //run the query which adds the data gathered from the form into the database $result = mysql_query("INSERT INTO news (title, dtime, text1, text2) VALUES ('$title',NOW(),'$text1','$text2')",$connect); //print success message. echo "<b>Thank you! News added Successfully!<br>You'll be redirected to Home Page after (4) Seconds"; echo "<meta http-equiv=Refresh content=4;url=index.php>"; }//end of if($submit). // If the form has not been submitted, display it!else {//begin of else ?> <br> <h3>::Add News</h3> <form method="post" action="<? echo $_SERVER['PHP_SELF'] ?>"> Title: <input name="title" size="40" maxlength="255"> <br> Text1: <textarea name="text1" rows="7"cols="30"></textarea> <br> Text2: <textarea name="text2" rows="7" cols="30"></textarea> <br> <input type="submit" name="submit" value="Add News"> </form><?php }//end of else?> and following is an error messageYou are not authorized to view this page You might not have permission to view this directory or page using the credentials you supplied. --------------------------------------------------------------------------------If you believe you should be able to view this directory or page, please try to contact the Web site by using any e-mail address or phone number that may be listed on the localhost home page.You can click Search to look for information on the Internet.HTTP Error 403 - Forbidden Internet Explorer whts problem i cannot understand.

You are better off with the full token there: <?phpAnd you still have no single quotes around the PHP_SELF.Also, please cut and paste the precise (actual) error message.
Link to comment
Share on other sites

You have to access the server through FTP, look at the files that your script or the browser is trying to access, and see if they have read permissions for the owner, group and user. This might be more helpful to you: http://www.interspire.com/content/articles...ile-Permissions

Link to comment
Share on other sites

thanx now the code is ok. but now i face another problem in another filethe code is:<title>News----By: maaking.com</title><?php//LAST UPDATE// 27-09-2007// load the configuration file.include("config.php"); //load all news from the database and then OREDER them by newsid //you will notice that newlly added news will appeare first. //also you can OREDER by (dtime) instaed of (news) $result = mysql_query("SELECT * FROM news ORDER BY id DESC",$connect); //lets make a loop and get all news from the database while($myrow = mysql_fetch_array($result)) {//begin of loop //now print the results: echo "<b>news: "; echo $myrow['news']; echo "</b><br>On: <i>"; echo $myrow['dtime']; echo "</i><hr align=left width=160>"; echo $myrow['text1']; // Now print the options to (Read,Edit & Delete the news) echo "<br><a href=\"read_more.php?id=$myrow[id]\">Read More...</a> || <a href=\"edit_news.php?id=$myrow[id]\">Edit</a> || <a href=\"delete_news.php?id=$myrow[id]\">Delete</a><br><hr>"; }//end of loop?><!-- here you have the right to go Home or Add News. It's HTML not PHP --><br><br><a href=aln.php>Home</a> <a href=add_news.php>Add News</a> the error comes is:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\portal\ALN.php on line 15now any one tell me whts the problem with my code?? :)

Link to comment
Share on other sites

Either the table "news" does not exist, or the "id" field doesn't exist. At least, from what I can see. Maybe it's something else that's not visible in the code you're giving.

Link to comment
Share on other sites

thanx.now this file is ok. now i have another problem related to login form. the code is as fallows:<html><head><title>Login Form</title><body background=new2.jpg><p> </p><br><br><br><br><br><br><form id="loginForm" name="loginForm" method="post" action="login-exec.php"> <table width="300" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <td width="112"><b>Login</b></td> <td width="188"><input name="login" type="text" class="textfield" id="login" /></td> </tr> <tr> <td><b>Password</b></td> <td><input name="password" type="password" class="textfield" id="password" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="Submit" value="Login" /></td> </tr> </table></form></body></html>when i login it gives error "login failed check user name and password". i give correct user name and password but problem remain.why?? :):):)

Either the table "news" does not exist, or the "id" field doesn't exist. At least, from what I can see. Maybe it's something else that's not visible in the code you're giving.
Link to comment
Share on other sites

its the code thats handle the login information<html><body background=new2.jpg)<?php //Start session session_start(); //Include database connection details require_once('configure.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Connect to mysql server $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if(!$link) { die('Failed to connect to server: ' . mysql_error()); } //Select database $db = mysql_select_db(sample_db); if(!$db) { die("Unable to select database"); } //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $login = clean($_POST['login']); $password = clean($_POST['password']); //Input Validations if($login == '') { $errmsg_arr[] = 'Login ID missing'; $errflag = true; } if($password == '') { $errmsg_arr[] = 'Password missing'; $errflag = true; } //If there are input validations, redirect back to the login form if($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: login-form.html"); exit(); } //Create query $qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'"; $result=mysql_query($qry); //Check whether the query was successful or not if($result) { if(mysql_num_rows($result) == 1) { //Login Successful session_regenerate_id(); $member = mysql_fetch_assoc($result); $_SESSION['SESS_MEMBER_ID'] = $member['member_id']; $_SESSION['SESS_FIRST_NAME'] = $member['firstname']; $_SESSION['SESS_LAST_NAME'] = $member['lastname']; session_write_close(); header("location: home.html"); exit(); }else { //Login failed header("location: login-failed.php"); exit(); } }else { die("Query failed"); }?></body></html>now can u tell mewhts the problem? :)

What's the code that handles the login information?
Link to comment
Share on other sites

I'd say that you somehow managed to put duplicate entries in the database. You should try to prevent that when users register.Try this:

if(mysql_num_rows($result) > 0) {

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...