FAQ |
Kalender |
![]() |
#1 | ||
|
|||
Nykomling
|
Hejsan alla wnare!
Jag har ett stort problem som jag inte riktigt fattar. Tror jag har sökt nästan överallt och försökt allt jag kan.. Men ser inte felet....... Snälla hjälp. Felet som blir är att när jag trycker på submit så avslutas session och jag måste logga in igen. Detta är koden efter en FORM posten. session_start(); if($_POST['tbName'] != "") { $name = $_POST['tbName']; $access = $_POST['radioAccess']; $title = $_POST['tbTitle']; $access = $_POST['radioAccess']; $body = $_POST['editorBody']; $body = str_replace('\"', '"', $body); $userID = $_SESSION['userID']; //sql_insert fungerar till 100% sql_insert("page", "name,access,title,body,userID,created", "'" . $name . "'," . $access . ",'" . $title . "','" . $body . "'," . $userID . ",'" . date("Y-m-d H:i:s") . "'", false); $template = file_get_contents("src/template_page.php"); $template = str_replace("@access", $access, $template); $template = str_replace("@pagename", $name . ".php", $template); $template = str_replace("@cachefolder", $name, $template); $template = str_replace("@title", $title, $template); $template = str_replace("@content", $body, $template); $ourFileName = $name . ".php"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); $stringData = $template; fwrite($ourFileHandle, $stringData); fclose($ourFileHandle); echo "Page created"; } Allt fungerar men jag blir utloggad fattar bara inte varför... |
||
![]() |
![]() |
![]() |
#2 | ||
|
|||
Har WN som tidsfördriv
|
Lite svårt att felsöka baserat på koden ovan. Har du slagit på alla felmeddelanden och varningar så du inte får någon hjälp där?
session_start() finns på alla sidor innan du hamnar på sidan som loggar ut dig? En helt annan sak, hoppas du validerar indata du får till sql_insert() ![]() |
||
![]() |
![]() |
![]() |
#3 | ||
|
|||
Nykomling
|
Nix ingen hjälp och session_start finns överallt
![]() Yes görs i funktionen ![]() |
||
![]() |
![]() |
![]() |
#4 | ||
|
|||
Klarade millennium-buggen
|
Utan att se hela koden är det svårt, eftersom man vill gärna se flödet.
Får $userID något värde? Vad sker innan och efter IF-satsen? |
||
![]() |
![]() |
![]() |
#5 | ||
|
|||
Nykomling
|
Så här ser hela koden ut hoppas det hjälper lite mer :=):
include_once 'qmnet/pageinclude.php';//Här i ligger session_start(); samt sql_insert funktionen if(isset($_GET['addsave'])) { $name = $_POST['tbName']; $access = $_POST['radioAccess']; $title = $_POST['tbTitle']; $access = $_POST['radioAccess']; $body = $_POST['editorBody']; $body = str_replace('\"', '"', $body); $userID = $_SESSION['userID']; //sql_insert fungerar till 100% sql_insert("page", "name,access,title,body,userID,created", "'" . $name . "'," . $access . ",'" . $title . "','" . $body . "'," . $userID . ",'" . date("Y-m-d H:i:s") . "'", false); $template = file_get_contents("src/template_page.php"); $template = str_replace("@access", $access, $template); $template = str_replace("@pagename", $name . ".php", $template); $template = str_replace("@cachefolder", $name, $template); $template = str_replace("@title", $title, $template); $template = str_replace("@content", $body, $template); $ourFileName = $name . ".php"; $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); $stringData = $template; fwrite($ourFileHandle, $stringData); fclose($ourFileHandle); echo "Page created"; } else { echo "<form method=\"post\" action=\"?addsave\">"; echo "Name: <input type=\"text\" name=\"tbName\" />(No space or special caracters like ÅÄÖ)<br />"; echo "Title: <input type=\"text\" name=\"tbTitle\" /><br />"; echo "Body:<br />" . $codeBody . "<br />"; echo "<input type=\"radio\" name=\"radioAccess\" value=\"0\" checked /> Public<br />"; echo "<input type=\"radio\" name=\"radioAccess\" value=\"1\" /> Member<br />"; echo "<input type=\"radio\" name=\"radioAccess\" value=\"3\" /> Admin<br />"; echo "<input type=\"submit\" value=\"Save\" />"; echo "</form>"; } |
||
![]() |
![]() |
![]() |
#6 | ||
|
|||
Mycket flitig postare
|
Du sätter inte $_SESSION['userID'] någonstans i den koden.
Du säger att sql_insert fungerar perfekt. Innebär det att även $userID (som sätts till samma som $_SESSION['userID']) blir korrekt? |
||
![]() |
![]() |
![]() |
#7 | ||
|
|||
Nykomling
|
$_SESSION['userID'] blir satt när man loggar in och det är man för jag får ett värde från den.
Men tror jag har lokaliserat problemet och det har något med mitt webbhotell att göra. |
||
![]() |
![]() |
Svara |
|
|