Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-10-2008, 02:16 PM
ptiteuf ptiteuf is offline
 
Join Date: May 2008
Location: BELGIQUE
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default [help] logue site / vbulletin

Hello all,

voila I would like a cree access login on the root of my site, then use the same login and pass that the forum, but when j'encode my login and pass it makes me tjrs a mistake. I put my three file I cree for that. saver if you help me verais ca me pleasure.

regrettable for the translation

page index.php

<form action="/session.php" method="post">
<input name="name" type="text" size="12" value="" /> Name<br />
<input name="pass" type="password" size="12" value="" /> Password<br />
<input name="submit" type="submit" value="Connexion" />
</form>

page auth.php

<?php
//on vérifie que l'utilisateur est identifé
if (!isset($_SESSION['name'])){
//si la variable de session n'existe pas
//on redirige l'utilisateur vers le formulaire d'identification
header('Location: ./index.php');
//on arrête l'exécution
exit();}
?>

page session.php

<?php
//initialisation de la session
session_start();
//si les champs ont été remplis
if (!$_POST['name']=="" && !$_POST['pass']==""){
//on récupère les valeurs des champs
$name = $_POST['username'];
$pass = md5($_POST['password']);

//connexion à la base de donnée
$connect = mysql_connect('serveur', 'nom dutilisateur', 'mdp');
mysql_select_db('nombdd', $connect);
$sql = mysql_query("SELECT password FROM username WHERE username='$name'");
$row = mysql_fetch_array($sql);
$pass_sql = $row['password'];

//on teste si le mot de passe correspond à la base de donnée
if ($pass_sql == $pass){
//l'utilisateur est valide
//on crée la variable de session avec son nom
$_SESSION['username'] = $name;
$msg = 'Vous êtes correctement indentifié';}
else{
//sinon on avertit l'utilisateur
$msg = 'Votre nom ou votre mot de passe est incorrect<br />';
$msg .= '<a href="/index.php">Retour</a>';}

//fermeture de la connexion
mysql_close();}
else{
//un des champs n'est pas rempli
$msg = 'Votre nom et/ou votre mot de passe n\'est pas renseigné<br />';
$msg .= '<a href="/index.php">Retour</a>';}

//on affiche le resultat
echo $msg;
?>
Reply With Quote
  #2  
Old 08-10-2008, 03:19 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You might want to look at this - Simple vB User login and access control on non vB pages or just trying searching on "login" "titles only" since this has been brought up before and the code it out there.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:32 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03377 seconds
  • Memory Usage 2,165KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete