Jump to content

Zephyris

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Zephyris's Achievements

Member

Member (2/5)

0

Reputation

  1. Yeah I've tried that too. But it doesn't seem to understand that it needs to get #menu_usager# from the header file. as in $tmp->replace("menu_usager",$tmp->user,$tmp->header); $tmp->header is where the header source is located so it should work. tried function replace($var, $content,$from) { $from = str_replace("#$var#", $content, $from); } and function replace($var, $content,$from) { $this->$from = str_replace("#$var#", $content, $from); } and other forms, I cannot get this to work however function replace($var, $content) { $this->template = str_replace("#$var#", $content, $this->template); } this is the original code which works.
  2. On the index page, it doesn't replace #menu_usager# by the user/guest menu at all. There must be something wrong with my replace function, what am I doing wrong? template system <? // Template & Layout class Template { // Variables public $default; public $header; public $user; public $content; public $footer; function load($page) { $this->header = file_get_contents($this->default ."hdp.html"); $this->content = file_get_contents($this->default ."$page.html"); $this->footer = file_get_contents($this->default ."bdp.html"); // Load User Menu depending on session. if($_SESSION['user']=="guest"){ $this->user = file_get_contents($this->default . "menu_guest.html"); } else { $this->user = file_get_contents($this->default . "menu_logged.html"); } } function replace($var, $content,$from) { $this->$from = str_replace("#$var#", $content, $this->$from); } function publish() { eval("?>". $this->header . $this->content . $this->footer ."<?"); } } ?> index page <? session_start(); if($_SESSION['user']==""){ $_SESSION['user']="guest"; } include "includes/class.php"; $tmp = new Template; $tmp->default="styles/origine/"; $tmp->load("p_index"); $tmp->replace("menu_usager",$tmp->user,$tmp->header); $tmp->publish(); ?>
  3. Wow thanks Paul got it to work with what you gave me. What's the difference between mysql_fetch_assoc and mysql_fetch_array? Should I not use array? if($result = mysql_query("SELECT * FROM `utilisateurs` WHERE cu='$uti' AND mdp= MD5('$mdp')")){ if(mysql_num_rows($result)) { $row = mysql_fetch_assoc($result); $_SESSION['utilisateur']=$row['cu']; $_SESSION['email'] =$row['em']; echo "<br> Connexion établie... <br><strong>Redirection vers la page d'accueil dans 3 secondes...</strong>"; echo '<meta http-equiv="refresh" content="3;url=index.php"> '; } else { echo '<br>ERREUR DE CONNEXION 30-GO ' . mysql_error(); echo '<meta http-equiv="refresh" content="5;url=index.php"> '; } } else { echo 'Erreur avec la demande. 50-GO'; } Thanks for the help!
  4. I'm fetching data from the db but I'm trying to know if the data exist and if it is correct then if it's wrong echo an error msg and if it's right echo a success msg. I'm probably doing something wrong here... I tried if(!result) and if(!row) both don't work. $result = mysql_query("SELECT * FROM `users` WHERE cu='$uti' AND mdp= MD5('$mdp')") or die(mysql_error()); $row = mysql_fetch_array($result) or die(mysql_error()); if (!$result) { echo 'ERREUR DE CONNEXION 23-GO ' . mysql_error(); //HERE wrong name or Password echo '<meta http-equiv="refresh" content="5;url=index.php"> '; } else { $_SESSION['utilisateur']=$row['cu']; //here great you've logged in $_SESSION['email']=$row['em']; echo "<br> Connexion établie... <br><b>Redirection vers la page d'accueil dans 3 secondes...</b>"; echo '<meta http-equiv="refresh" content="3;url=index.php"> '; } } Loging in works perfectly however, if I enter bad username or password it never gets to the error msg. hmmm. Thanks for the help in advance guys.
  5. Variables were all set, I just removed the isset from my $_GET["v"]=='dc' and that fixed it. I also tried ur (isSet($_GET['v']) && $_GET['v'] == 'dc') which also worked. Thanks PaulRyan
  6. I'm trying to make a page with multiple $_GET situations example if my user wants to log out, he clicks the loggout link which sends him to user.php?v=dc if($_GET['v']=="dc") { session_destroy(); exit; } if(isset($_GET['v'])=="dc") { session_destroy(); exit; } but it seems no matter where the user goes it destroys the session. if($_GET['v']=="mail") { // show mail } but instead it does what's in $_GET['v']=="dc" <?php if(isset($_GET["v"])=="dc"){ if($_SESSION[user]=='Guest'){ echo "You are not logged in fool."; exit; }else{ echo "Session closed!"; session_destroy(); } } ?> That above doesn't work, when I go elsewhere it still destroy the session... no matter if it's a guest or not. If I go to ($_GET['v']=="godknows") as a user and not a guest, it will destroy the session. I get the strangest errors... S.O.S
  7. I uploaded it to my website and to my suprise it works... So I'm guessing my easyphp on my computer that I use to test my code is out of date or misfunctioning.
  8. It's been awhile since I coded php so I'm trying to check what I'm doing wrong... session_start(); $_SESSION['utilisateur']="Invite"; if($_SESSION['utilisateur'] == "Invite") { $dlogin = file_get_contents('display_login.html'); } else { $dlogin = file_get_contents('display_usermenu.php'); } echo($dlogin); Notice: Undefined variable: _SESSION in C:\Program Files (x86)\EasyPHP-5.3.4.0\www\index.php on line 21 line 21 being if($_SESSION ... hmmm, im confused i dont see any syntax errors, do you?
  9. I'm having a huge memory blank on whats its called and how you do it, I just restarted php @__@ Basicly I just wana do if index.php has do=login then { do this here } lol, sorry for the stupid question o.o
  10. My title says it all... Basicly I'm trying to add video sharing feature to my website but I can't seem to figure out a few things and I dont know where to post this topic, but you guys have always been of great help so I decided to post it here I need to be able to play .FLV files through a flash player however my main problem is uploading those video.. How would I make it so a user can upload any type of video which would be converted to .FLV in the upload process??? Converting the video to .flv via an activeX or javascript onsite using client's power. This above is my main problem^^^ I would appreciate any help... there's no answer I could find for my problem on the internet :S
  11. i was thinking of doing this for my forum polls db, but id need a vote table to check account id and ips. thats what im doing for my weekly poll.. adding a vote db with account id and ip so u can check for double votes.
  12. I fixed it myself, it happens it just didn't like my code. I optimized it and now it works... awesome uh for those interested: // Check Options / Answers for( $num=1; $num < 10; $num += 1 ){ if( !empty($row2['option'.$num]) ) { echo '<tr><td bgcolor="#000000"> <input name="" type="radio" value="" />'.($row2['option'.$num]).'</td></tr>'; } }
  13. Thanks for the replies, the thing is I'm not getting any error and I just added the "or die.." and fixed some of the things.. at first it was displaying all 10 options... until I added in if empty... options contain text.. it's basicly all the answers possible.. up to 10 answers max. I'm doing this check to see which is empty... and calculating the total of options that aren't empty so I can then echo the answers up to the last none empty one. I'm using date,time separatly because sometimes I just want the date and sometimes just the time...
  14. I'll start off by saying hi and thanks in advance. This is a poll script, in my mysql I have a table named weekly_polls( id,author, question, date, time, option1, option2 ~ upto option10 ) Options are possible answers to the poll. What I'm trying to do is a loop that get's all those options(answers) and display them on my page only if the field of the table is not empty. So I came up with this: // Weekly Poll $result2 = mysql_query("SELECT * FROM `weekly_polls` ORDER BY `date`, `time` DESC LIMIT 1"); $row2 = mysql_fetch_array($result2) // Check Options / Answers $oavail = 0; if(!empty($rows2['option1'])){ $oavail += 1; } if(!empty($rows2['option2'])){ $oavail += 1; } if(!empty($rows2['option3'])){ $oavail += 1; } if(!empty($rows2['option4'])){ $oavail += 1; } if(!empty($rows2['option5'])){ $oavail += 1; } if(!empty($rows2['option6'])){ $oavail += 1; } if(!empty($rows2['option7'])){ $oavail += 1; } if(!empty($rows2['option8'])){ $oavail += 1; } if(!empty($rows2['option9'])){ $oavail += 1; } if(!empty($rows2['option10'])){ $oavail += 1; } for( $num=1; $num < $oavail; $num += 1 ){ echo('<tr><td bgcolor="#000000"> <input name="" type="radio" value="" />'.($row2['option'.$num]).'</td></tr>'); } But the thing is, it isnt workign yet... it's not displaying anything.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.