Pagina 1 din 1

Problema cu header redirect in php

Scris: Sâm Iul 31, 2010
de Wayn3
am aceste trei pagini .. incerc sa fac o pagina de postat si de redirectionat automat catre pagina in care pot vizualiza datele introduse extragand din baza de date nr-ul .id...
dar cand postez imi arata link-ul : http:// www .domeniu.com/film.php?id= .. .si nu vrea sa extraga "id" din baza de date
addvideo.php :

Cod: Selectaţi tot

<form action="insert_video.php" method="post">
<tr><td>Video Title:</td><td>
<input type="text" name="video_title"></td></tr> <br>
<tr><td>Continut:</td><td><br>
<textarea rows="7" name="video_continut" cols="30"></textarea></td></tr> <br>
<tr><td>Descriere:</td><td><br>
<textarea rows="10" name="video_details" cols="40"></textarea></td></tr> <br>
<tr><td colspan="2" align="right">
<center><input type="reset" name="reset" value="Reset">
<input type="submit" name="submit" value="Adauga film" onClick="return verifica(this.form)"></center>
<tr><td colspan="2" align="left"><a href="main.php">Back to Main</a></td></tr>
</table>
</form>
insert_video.php

Cod: Selectaţi tot

<?
if($_POST['video_title']!=null && $_POST['video_continut']!=null && $_POST['video_details']!=null){

$video_title=$_POST['video_title'];
$video_continut=$_POST['video_continut'];
$video_details=$_POST['video_details'];

$query="INSERT INTO `video` (`video_title`,`video_continut`,`video_details`) VALUES ('".$video_title."','".$video_continut."','".$video_details."')";
mysql_query($query) or die(mysql_error());

header('Location: film.php?id='.$row['id']);
}else{
header('Location: addvideo.php');
}
?>
film.php

Cod: Selectaţi tot

<?
/**
* Main.php
*
* This is an example of the main page of a website. Here
* users will be able to login. However, like on most sites
* the login form doesn't just have to be on the main page,
* but re-appear on subsequent pages, depending on whether
* the user has logged in or not.
*
* Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
* Last Updated: August 26, 2004
*/
include("include/session.php");
?>

<html>
<title>Jpmaster77's Login Script</title>
<body>

<table>
<tr><td>






<?
/**
* User has already logged in, so display relavent links, including
* a link to the admin center if the user is an administrator.
*/
if($session->logged_in){
echo "<h1>Logged In</h1>";
echo "Welcome <b>$session->username</b>, you are logged in. <br><br>"
."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] &nbsp;&nbsp;"
."[<a href=\"useredit.php\">Edit Account</a>] &nbsp;&nbsp;";
if($session->isAdmin()){
echo "[<a href=\"admin/admin.php\">Admin Center</a>] &nbsp;&nbsp;";
}
echo "[<a href=\"process.php\">Logout</a>]";
}
else{

}
?>

<h1>FILME</h1>
<?

if($_GET['id']!=null){
$sql="SELECT * FROM `video` WHERE id='".$_GET['id']."'";
$r=mysql_query($sql);
while($row = mysql_fetch_array($r)){

echo $row['video'];
}
}
else{

header('Location: addvideo.php');


}
?>


</td></tr>
</table>

</body>
</html>
auzisem ca ceva din header nu e bine scris .. ma puteti ajuta ?

Problema cu header redirect in php

Scris: Sâm Iul 31, 2010
de MarPlo
Nu merge fiindca in "insert_video.php" nu e preluata valoare pt. $row['id'] inainte de a fi folosit in header-redirect.
Daca 'id' e coloana AUTO_INCREMENT, adauga in "insert_video.php", imediat dupa: " mysql_query($query) or die(mysql_error()); "
$row['id'] = mysql_insert_id();
Daca nu merge asa, trebuie ca inainte de acel header pt. redirect sa mai faci un SELECT in mysql din care sa extragi acel "id" pe care-l folosesti la adresa din header.

Problema cu header redirect in php

Scris: Sâm Iul 31, 2010
de Wayn3
sa stii ca a functionat .. merci foarte mult :D