Forum Moderators: coopster

Message Too Old, No Replies

Dont show update page

Dont want people to see the update page

         

Twisted Mind

9:48 am on Nov 8, 2005 (gmt 0)

10+ Year Member



I dont want people to see my update script more like when they press update the page will refresh with the new entry..

Anyone who can tell me how to do it.

NomikOS

10:16 am on Nov 8, 2005 (gmt 0)

10+ Year Member



more info please. I don't understand you

dreamcatcher

10:21 am on Nov 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sounds like you need the header() function.

[uk2.php.net...]

NomikOS

10:28 am on Nov 8, 2005 (gmt 0)

10+ Year Member



yes dreamcatcher, seems that:

Twisted Mind see this:


For avoid resubmitting you must use something like this:

header ('location: page you want');
exit;

Inmediatly after POST (in same request) -> if user reload page, the form is not submit again.


if it is, study what dreamcatcher says.

---

Twisted Mind

10:39 am on Nov 8, 2005 (gmt 0)

10+ Year Member



i think it is what i need ill look into it

dreamcatcher

11:20 am on Nov 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You`ll need to be careful with the header function if you haven`t used it before. No output can be sent to the browser before you call this function or else you will see an error.

Good luck.

Twisted Mind

12:03 pm on Nov 8, 2005 (gmt 0)

10+ Year Member



What do u mean with being carfully with it i dind see an error.. but anyway can some1 tell me how to echo your root url like when u just use an ip it would echo you ip with a var or on www.example.com that it would be capable to echo that (like whenu change url it will still work :))

RonPK

1:40 pm on Nov 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I guess you're looking for $_SERVER['HTTP_HOST']

NomikOS

3:01 pm on Nov 8, 2005 (gmt 0)

10+ Year Member



what? :)

In the hurry I think the same, look for:
1) header()
2) $_SERVER['HTTP_HOST']

Twisted Mind read the manual as you was suggested. you will have answers for both questions there.

---

Twisted Mind

3:03 pm on Nov 8, 2005 (gmt 0)

10+ Year Member



thats it :)

Twisted Mind

3:06 pm on Nov 8, 2005 (gmt 0)

10+ Year Member



lol sorry :P but it works already

dreamcatcher

3:34 pm on Nov 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What do u mean with being carfully with it i dind see an error

That means you are using it correctly then. :P

Twisted Mind

8:04 pm on Nov 8, 2005 (gmt 0)

10+ Year Member



I dont really know if im retarded but now i do get an error whats wrong with this and can u tell me why then i wont make the mistake again:
<html>
<? include "dbconn.php";

$title = $_POST['title'];
echo "$title";
$link = $_POST['link'];
echo "$link";
$content = $_POST['content'];
echo "$content";

$query = " INSERT INTO example(title,link,content) VALUES ('$title','$link','$content')";
$result = @ mysql_query($query,$connection) or die(mysql_error());

header("Location: [localhost...]
die;
?>
</html>

error: Warning: Cannot modify header information - headers already sent by (output started at C:\xamp\xampp\htdocs\noobgamers\updatepage.php:2) in C:\xamp\xampp\htdocs\noobgamers\updatepage.php on line 15

chriswragg

8:21 pm on Nov 8, 2005 (gmt 0)

10+ Year Member



No output can be sent to the browser before you call this function or else you will see an error.

You've done exactly what dreamcatcher warned you not to do! No output (ie ECHO or PRINT) can be used before the header function or you will recieve this error

chriswragg

8:28 pm on Nov 8, 2005 (gmt 0)

10+ Year Member



Also noticed the <html> tag at the start of the script. That will also trigger an error.

The header function you are using will instantly redirect the users browser without them even viewing the page, so there is no need for anything to be output, even the html.

Twisted Mind

7:08 am on Nov 9, 2005 (gmt 0)

10+ Year Member



oh i understand now thanks

Twisted Mind

7:15 am on Nov 9, 2005 (gmt 0)

10+ Year Member



Does it have a problem with the variables too? i think it does but if i change the variables in query to post i get this error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xamp\xampp\htdocs\noobgamers\updatepage.php on line 5

Twisted Mind

7:17 am on Nov 9, 2005 (gmt 0)

10+ Year Member



script if u need to see it:

<? include "dbconn.php";

$query = " INSERT INTO example(title,link,content) VALUES ('$_POST['title']','$_POST['link']','$_POST['content']')";
$result = @ mysql_query($query,$connection) or die(mysql_error());

header("Location: [localhost...]
die;
?>

NomikOS

8:20 am on Nov 9, 2005 (gmt 0)

10+ Year Member



try this, note {} signs:


$query = " INSERT INTO example (title,link,content) VALUES ('{$_POST['title']}','{$_POST['link']}','{$_POST['content']}')";

Twisted Mind

8:25 am on Nov 9, 2005 (gmt 0)

10+ Year Member



ill try that when im home

Twisted Mind

12:54 pm on Nov 9, 2005 (gmt 0)

10+ Year Member



changed it as u can see:

<?

include "dbconn.php";

$query = " INSERT INTO example(title,link,content) VALUES ('{$_POST['title']}','{$_POST['link']}','{$_POST['content']}')";
$result = @ mysql_query($query,$connection) or die(mysql_error());

header("Location: [localhost...]
die;
?>

This error now :

Warning: Cannot modify header information - headers already sent by (output started at C:\xamp\xampp\htdocs\noobgamers\updatepage.php:2) in C:\xamp\xampp\htdocs\noobgamers\updatepage.php on line 11

Twisted Mind

1:10 pm on Nov 9, 2005 (gmt 0)

10+ Year Member



Help Me

chriswragg

5:59 pm on Nov 9, 2005 (gmt 0)

10+ Year Member



Warning: Cannot modify header information - headers already sent by (output started at C:\xamp\xampp\htdocs\noobgamers\updatepage.php:2) in C:\xamp\xampp\htdocs\noobgamers\updatepage.php on line 11

Are you sure this is ALL of the file and the exact same code?

In the error, it says line 11 contains the header function, however in the code you are posting, it apperars on line 8. The :2 after the url in the error says the line on which something is output to the page (If there is anything written before the script line 2 will contain the <? tag).

Check there is no typing before the php in your file, even a return will trigger this error.

Twisted Mind

7:32 am on Nov 10, 2005 (gmt 0)

10+ Year Member



i put some enters with it to make it look nicer:

<?

include "dbconn.php";

$query = " INSERT INTO example(title,link,content) VALUES ('{$_POST['title']}','{$_POST['link']}','{$_POST['content']}')";
$result = @ mysql_query($query,$connection) or die(mysql_error());

header("Location: [localhost...]
die;
?>

error:

Warning: Cannot modify header information - headers already sent by (output started at C:\xamp\xampp\htdocs\noobgamers\updatepage.php:2) in C:\xamp\xampp\htdocs\noobgamers\updatepage.php on line 11

Twisted Mind

7:39 am on Nov 10, 2005 (gmt 0)

10+ Year Member



dbconn:

<?

//Get Host
$Host ="localhost";

//Select Database
$Database ="guildwars";

//Get database User
$User ="#*$!xxx";

//Get database Password
$Password ="xxxxxx";

// Connect to host
$connection = mysql_connect ($Host,$User,$Password);

@mysql_select_db('guildwars');

?>

Twisted Mind

7:43 am on Nov 10, 2005 (gmt 0)

10+ Year Member



oh wait u cant have?

<?<?dbconn?> header?>

ill change that

Twisted Mind

7:45 am on Nov 10, 2005 (gmt 0)

10+ Year Member



hmm doesnt work just outputs the code of dbconn...

NomikOS

8:37 am on Nov 10, 2005 (gmt 0)

10+ Year Member



I'm very sure that:

----------------------- top of file -----------------------
<-- this invisible line output before than header()
<?

include "dbconn.php";

...

search for that in all files (this, dbconn, config, etc) than participate in the execution.

Now certainly i go down... ZZZZZZZzzzz

---

Twisted Mind

8:50 am on Nov 10, 2005 (gmt 0)

10+ Year Member



Oh u cant comment say that then there are actually a couple of them in dbconn

Twisted Mind

8:52 am on Nov 10, 2005 (gmt 0)

10+ Year Member



removed them but still gives the error...
This 35 message thread spans 2 pages: 35