just some suggestion to add
- dummy block with block template
- add two three pages..
- function add/edit delete
- able to find the pages through search.php
- submenus
- simple admin page
etc
it will be much easier for user
$employee_id = $xoopsDB->escape($_GET['id']);
$check= $xoopsDB->query("SELECT * FROM ".$xoopsDB->prefix("employee")." WHERE id='$employee_id' ") or die(mysql_error());
<?php
/**
* modified from script by christian@frxoops.org
* Import users from a csv file into xoops 2.5.8
*
* Put this file and your users.cvs file in the root of your site
* go to http://yoursite/import_users.php in your browser
* click the button to rn the import
*
* Don't forget to DELETE it after you run it!
*/
/* Example users.csv file:
Bill;Barra;bill.barra@yahoo.com;changeme
Mark;Knopfler;mark@knopfler.com;changeme
Jim;Morrison;jim.morrison@gmail.com;changeme
Roger;Daltrey;roger@daltrey.com;changeme
*/
// assuming this is in the web root
include 'mainfile.php';
// make sure we run as a POST transaction, so database operations do not need "force"
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
echo '<form action="" method="POST"><input type="submit" value="Click to import"></form>';
exit();
}
$fichier = 'users.csv'; // data file as : first name(pseudo);last name;email;password
// remove line break on last record
/** @var XoopsMemberHandler $memberHandler */
$memberHandler = xoops_getHandler('member');
if (false === $memberHandler) die("Unable to create member handler");
$time = time();
// Open file for read
if (file_exists($fichier))
$fp = fopen("$fichier", "r");
else{ // unknown file
echo "File not found !Import stopped.n";
exit();
}
echo '<pre>Begin file import '.$fichier."n";
// import line by line
while (!feof($fp)) {
$ligne = fgets($fp, 4096);
if ('' === trim($ligne)) {
continue; // blank line
}
$liste = explode(";", $ligne); // create array
foreach ($liste as $index => $value) {
$liste[$index] = trim($value);
}
/** @var XoopsUser $user */
$user = $memberHandler->createUser();
$user->setVar('uname', $liste[0]);
$user->setVar('name', $liste[1]);
$user->setVar('email', $liste[2]);
$user->setVar('pass', md5($liste[3]));
$user->setVar('user_regdate', $time);
$user->setVar('user_level', 1); // activated
$user->setVar('user_viewemail', 1);
$user->setVar('user_avatar', 'avatars/blank.gif');
$uid = $memberHandler->insertUser($user);
if (false === $uid) {
echo sprintf("Failed to insert user %s n", $liste[0]);
echo "Importation stoppée.n</pre>";
fclose($fp);
exit();
}
$memberHandler->addUserToGroup(XOOPS_GROUP_USERS, $uid);
echo sprintf("Record %d - %s addedn", $uid, $user->uname());
}
echo "Import finished successfully.n</pre>";
fclose($fp);
Unknown: call_user_func() expects parameter 1 to be a valid callback, non-static method DefacerCorePreload::eventSystemClassGuiHeader() should not be called statically in file /class/preload.php line 139
Unknown: Non-static method DefacerCorePreload::eventCoreHeaderAddmeta() should not be called statically in file /modules/defacer/preloads/core.php line 85
Unknown: Non-static method DefacerCorePreload::isActive() should not be called statically in file /modules/defacer/preloads/core.php line 60
Unknown: Only variables should be assigned by reference in file /modules/defacer/preloads/core.php line 196
Unknown: Non-static method DefacerCorePreload::isRedirectActive() should not be called statically in file /modules/defacer/preloads/core.php line 60
Unknown: Only variables should be assigned by reference in file /modules/defacer/class/defacer.php line 156
Unknown: Only variables should be assigned by reference in file /modules/defacer/class/defacer.php line 142
Unknown: Only variables should be assigned by reference in file /modules/defacer/class/defacer.php line 143
Unknown: Only variables should be assigned by reference in file /modules/mylinks/xoops_version.php line 119
Unknown: Only variables should be assigned by reference in file /modules/mylinks/xoops_version.php line 120
Unknown: Only variables should be assigned by reference in file /modules/mylinks/xoops_version.php line 121
Unknown: Only variables should be assigned by reference in file /modules/xoopstube/xoops_version.php line 193
Unknown: Only variables should be assigned by reference in file /modules/xoopstube/xoops_version.php line 194
Unknown: Only variables should be assigned by reference in file /modules/xoopstube/xoops_version.php line 199
Unknown: Only variables should be assigned by reference in file /modules/tag/admin/menu.php line 25
Unknown: Only variables should be assigned by reference in file /modules/tag/admin/menu.php line 26
Unknown: Only variables should be assigned by reference in file /modules/tag/admin/menu.php line 27
Unknown: Only variables should be assigned by reference in file /modules/xoopspoll/admin/menu.php line 39
Unknown: Only variables should be assigned by reference in file /modules/xoopspoll/admin/menu.php line 40
Unknown: Only variables should be assigned by reference in file /modules/xoopspoll/admin/menu.php line 41
Unknown: Only variables should be assigned by reference in file /modules/xforms/admin/menu.php line 30
Unknown: Only variables should be assigned by reference in file /modules/xforms/admin/menu.php line 31
Unknown: Only variables should be assigned by reference in file /modules/xforms/admin/menu.php line 32
Unknown: Only variables should be assigned by reference in file /modules/isearch/xoops_version.php line 95
Notice: Use of undefined constant _PROFILE_MI_HOME - assumed '_PROFILE_MI_HOME' in file /modules/profile/admin/menu.php line 42
Notice: Use of undefined constant _PROFILE_MI_ABOUT - assumed '_PROFILE_MI_ABOUT' in file /modules/profile/admin/menu.php line 66
<?php
// christian@frxoops.org - http://www.frxoops.org
// Import users from a csv file into xoops 2.0.x
// 26 january 2006 : add trim() for encrypt password
// variables
$bdd= "x20132";
$host= "localhost";
$user= "root";
$pass= "";
$fichier = "users.csv"; // data file as : first name(pseudo);last name;email;password
// remove line break on last record
mysql_connect($host,$user,$pass) or die("Unable to connect Database");
mysql_select_db($bdd);
// Open file for read
if (file_exists($fichier))
$fp = fopen("$fichier", "r");
else{ // unknown file
echo "File not found !Import stopped.";
exit();
}
echo 'Begin file import '.$fichier.'';
// import line by line
while (!feof($fp)){
$ligne = fgets($fp,4096);
$liste = explode(";",$ligne); // create array
$user = $liste[0]; //first field
$name = $liste[1]; //second field
$email= $liste[2];
$pass= md5(trim($liste[3]));
// Add user in xoops_users table
$query = "insert into xoops_users (uname, name, email, pass) VALUES ('$user', '$name','$email','$pass')";
$result= mysql_query($query);
$uid = mysql_insert_id();
//Add user in group : users registered
$numgroup ='2';
$query = "INSERT INTO xoops_groups_users_link (groupid, uid) VALUES('$numgroup', '$uid')";
$result= mysql_query($query);
if (mysql_error()){
echo "Error in database : ".mysql_error();
echo "Importation stoppée.";
fclose($fp);
exit();
}else{
echo "Record ".$uid." - ".$user." added ";
}
}
echo "Import finished successfully.";
fclose($fp);
Bill;Barra;bill.barra@yahoo.com;245AVB
Mark;Knopfler;mark@knopfler.com;AVB245
Jim;Morrison;jim.morrison@gmail.com;bngh123
Roger;Daltrey;roger@daltrey.com;XXD23
<?php
// christian@frxoops.org - http://www.frxoops.org
// Import users from a csv file into XOOPS 2.0.x
// variables
$db= "test";
$host= "localhost";
$user= "root";
$pass= "";
$fichier = "users.csv"; // data file as : user name;real name;email;password
// remove line break on last record
mysql_connect($host,$user,$pass) or die("Unable to connect Database");
mysql_select_db($db);
// Open file for read
if (file_exists($fichier))
$fp = fopen("$fichier", "r");
else{ // unknown file
echo "File not found !Import stopped.";
exit();
}
echo 'Begin file import '.$fichier.'';
// import line by line
while (!feof($fp)){
$ligne = fgets($fp,4096);
$liste = explode(";",$ligne); // create array
$user = $liste[0]; //first field
$name = $liste[1]; //second field
$email= $liste[2];
$pass= md5($liste[3]);
// Add user in xoops_users table
$query = "insert into x536_users (uname, name, email, pass) VALUES ('$user', '$name','$email','$pass')";
$result= mysql_query($query);
$uid = mysql_insert_id();
//Add user in group : users registered
$numgroup ='2';
$query = "INSERT INTO x536_groups_users_link (groupid, uid) VALUES('$numgroup', '$uid')";
$result= mysql_query($query);
if (mysql_error()){
echo "Error in database : ".mysql_error();
echo "Importation stoppée.";
fclose($fp);
exit();
}else{
echo "Record ".$uid." - ".$user." added ";
}
}
echo "Import finished successfully.";
fclose($fp);
geekwright wrote:
The BEST way is to do this:$employee_id = $xoopsDB->escape($_GET['id']);
That will continue to work no matter what the underlying database driver is in the future.
Quote:
mjoel wrote:
since mysql_real_escape_string is deprecated
if i have this code$employee_id = mysql_real_escape_string($_GET['id']);
what should i replace it with