this is what i have:
i am using ravennuke which is a web based content management system (CMS) for clan websites.
i am trying to create a form by where the user has to fill in certain data so it gets processed to the sql database so that info gets passed onto the admin page where i can view who has registered for full membership and with what credentials.
these are my scripts:
this one is the install file that installs all the data needed for the database.
Code: Select all
<?php
require_once("mainfile.php");
global $admin, $prefix, $db;
if(!is_array($admin)) {
$adm = base64_decode($admin);
$adm = explode(":", $adm);
$admin_name = "$adm[0]";
} else {
$admin_name = "$admin[0]";
}
$isadmin = $db->sql_fetchrow($db->sql_query("SELECT * FROM ".$prefix."_authors WHERE aid='$admin_name'"));
if ($isadmin['radminsuper']==1) {
switch($op) {
default:
$pagetitle = "Join Us";
include("header.php");
title("$pagetitle");
OpenTable();
echo "<table align='center' border='0' cellpadding='2' cellspacing='2'>\n";
echo "<form action='".$_SERVER['PHP_SELF']."' method='post'>\n";
echo "<tr><td>This script will install or upgrade the tables for the $pagetitle.</td></tr>\n";
echo "<tr><td><b>Backup data tables before going on!</b></td></tr>\n";
echo "<tr><td><select name='op'>\n";
echo "<option value=''>--- Install Options ---</option>\n";
echo "<option value='install'>Install</option>\n";
echo "<option value='update'>Update</option>\n";
echo "<option value='uninstall'>Uninstall</option>\n";
echo "</select> <input type='submit' value='Commit'></td></tr>\n";
echo "<tr><td><b>Once you have finished with this script, delete it from your server!</b></td></tr>\n";
echo "</form>";
echo "</table>\n";
CloseTable();
include("footer.php");
break;
case "install":
$pagetitle = "Join Us: Install";
include("header.php");
title("$pagetitle");
OpenTable();
$db->sql_query("CREATE TABLE ".$prefix."_joinus_apps (
aid INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
realname VARCHAR( 25 ) NOT NULL ,
gamename VARCHAR( 25 ) NOT NULL ,
email VARCHAR( 50 ) NOT NULL ,
gender INT( 1 ) NOT NULL ,
day VARCHAR( 2 ) NOT NULL ,
month VARCHAR( 2 ) NOT NULL ,
year VARCHAR( 4 ) NOT NULL ,
country INT( 1 ) NOT NULL ,
xfire VARCHAR (25) NOT NULL ,
games INT( 1 ) NOT NULL ,
microphone INT( 1 ) NOT NULL ,
teamspeak2 INT( 1 ) NOT NULL ,
date VARCHAR( 10 ) NOT NULL)");
echo "Done!<br>\n";
echo "<a href=\"index.php\">Go back to index</a>\n";
CloseTable();
include("footer.php");
break;
case "update":
$pagetitle = "Join Us: Update";
include("header.php");
title("$pagetitle");
OpenTable();
$db->sql_query("ALTER TABLE ".$prefix."_joinus_apps ADD age INT( 3 ) NOT NULL AFTER email");
echo "Done!<br>\n";
echo "<a href=\"index.php\">Go back to index</a>\n";
CloseTable();
include("footer.php");
break;
case "uninstall":
$pagetitle = "Join Us: Uninstall";
include("header.php");
title("$pagetitle");
OpenTable();
$db->sql_query("DROP TABLE ".$prefix."_joinus_apps");
echo "Done!<br>\n";
echo "<a href=\"index.php\">Go back to index</a>\n";
CloseTable();
include("footer.php");
break;
}
} else {
$pagetitle = "Join Us: ERROR";
include("header.php");
title("$pagetitle");
OpenTable();
echo "<center><b>Sorry, ONLY super admins may run this script</b><center>\n";
CloseTable();
include("footer.php");
}
?>
this is the part that the user has to fill in:
Code: Select all
<?php
if (!defined('MODULE_FILE')) {
die ("You can't access this file directly...");
}
///////////////////////////////////////////////////
//Choose to send a mail here !! (Yes = 1, No = 0)//
///////////////////////////////////////////////////
$sendmail = 1;
///////////////////////////////////////////////////
///////////////////////////////////////////////////
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
$pagetitle = "- Clan Application";
get_lang($module_name);
function Index(){
global $db, $prefix, $cookie, $user, $module_name, $gfx_chk, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4;
include("header.php");
if(is_user($user)){
cookiedecode($user);
$username = $cookie[1];
}
OpenTable();
echo"<center><font size='24' class='title'><b>Clan Application</b></font><br><hr><br>
<span style='color:#FF3333;'><b>PLEASE NOTE!</b></span><br><br>
If you want to apply for Full Membership into our gaming clan, then please complete our application form below.<br />
Our recruitment officer will review your application and contact you via your registered email.<br />
We encourage all new applicants to please be patient, you will be contacted.<br><br>
Thank You<br><br><hr><br>
<table><tr><td>
<form method='post' action='modules.php?name=$module_name&op=Apply'>
<table border='0' cellspacing='2' cellpadding='3'>
<tr><td align='right'><b>Your Real Name:</b><br></td>
<td align='left'><input type='text' name='realname' value='$realname' size=35><br></td></tr>
<tr><td align='right'><b>Your Gaming Name:</b></td>
<td align='left'><input type='text' name='gamename' value='$gamename' size=35></td></tr>
<tr><td align='right'><b>Your E-mail:</b><br></td>
<td align='left'><input type='text' name='email' value='$email' size=35><br></td></tr>
<tr><td align='right'><b>Gender:</b><br></td>
<td align='left'><select name ='gender' value='$gender'>
<option value=''></option>
<option value='1'>Male</option>
<option value='0'>Female</option>
</select><br></td></tr>
<tr><td align='right'> <b>Date of Birth:</b></td>
<td align='left'><input type='text' name='day' value='$day' size=2> <input type='text' name='month' value='$month' size=2> <input type='text' name='year' value='$year' size=4></td></tr>
<tr><td align='right'></b></td>
<td align='left'> <font style='font-size:9px;'>(dd-mm-yyyy )</font></td></tr>
<tr><td align='right'><b>Country:</b><br></td>
<td align='left'><select name ='country' value='$country'>
<option value=''></option>
<option value='Albania'>Albania</option>
<option value='Andorra'>Andorra </option>
<option value='Argentina'>Argentina </option>
<option value='Australia'>Australia </option>
<option value='Austria'>Austria </option>
<option value='Belarus'>Belarus </option>
<option value='Belgium'>Belgium </option>
<option value='Brazil'>Brazil </option>
<option value='Bolivia'>Bolivia </option>
<option value='Bosnia'>Bosnia </option>
<option value='Bulgaria'>Bulgaria </option>
<option value='Canada'>Canada </option>
<option value='Chile'>Chile </option>
<option value='China'>China </option>
<option value='Colombia'>Colombia </option>
<option value='Croatia'>Croatia </option>
<option value='Cyprus'>Cyprus </option>
<option value='CzechRep'>CzechRep </option>
<option value='Denmark'>Denmark </option>
<option value='England'>England </option>
<option value='Estonia'>Estonia </option>
<option value='Finland'>Finland </option>
<option value='France'>France </option>
<option value='Germany'>Germany </option>
<option value='Greece'>Greece </option>
<option value='Hungary'>Hungary </option>
<option value='Iceland'>Iceland </option>
<option value='India'>India </option>
<option value='Iraq'>Iraq </option>
<option value='Ireland'>Ireland </option>
<option value='Israel'>Israel </option>
<option value='Italy'>Italy </option>
<option value='Jamaica'>Jamaica </option>
<option value='Japan'>Japan </option>
<option value='Korea'>Korea </option>
<option value='Latvia'>Latvia </option>
<option value='Liechtenstein'>Liechtenstein </option>
<option value='Lithuania'>Lithuania </option>
<option value='Luxembourg'>Luxembourg </option>
<option value='Macedonia'>Macedonia </option>
<option value='Malta'>Malta </option>
<option value='Mexico'>Mexico </option>
<option value='Moldova'>Moldova </option>
<option value='Monaco'>Monaco </option>
<option value='Morocco'>Morocco </option>
<option value='Netherlands'>Netherlands </option>
<option value='New Zealand'>New Zealand </option>
<option value='Nigeria'>Nigeria </option>
<option value='Norway'>Norway </option>
<option value='Paraguay'>Paraguay </option>
<option value='Poland'>Poland </option>
<option value='Portugal'>Portugal </option>
<option value='Romania'>Romania </option>
<option value='Russia'>Russia </option>
<option value='San Marino'>San Marino </option>
<option value='Scotland'>Scotland </option>
<option value='Singapore'>Singapore </option>
<option value='Slovakia'>Slovakia </option>
<option value='Slovenia'>Slovenia </option>
<option value='South Africa'>South Africa </option>
<option value='Spain'>Spain</option>
<option value='Sweden'>Sweden</option>
<option value='Switzerland'>Switzerland</option>
<option value='Tunisia'>Tunisia</option>
<option value='Turkey'>Turkey</option>
<option value='Ukraine'>Ukraine</option>
<option value='United States'>United States </option>
<option value='Uraguay'>Uraguay</option>
<option value='Venezuela'>Venezuela</option>
<option value='Wales'>Wales</option>
<option value='Yugoslavia'>Yugoslavia</option>
</select><br></td></tr>
<tr><td align='right'><b>Xfire:</b><br></td>
<td align='left'><input type='text' name='xfire' value='$xfire' size=35><br></td></tr>
<tr><td align='right' valign='top'> <b>Select Games You Own:</b></td>
<td align='left'>
<input type='checkbox' name='games[]' value='CODUO'> Call Of Duty United Offensive<br>
<input type='checkbox' name='games[]' value='COD2'> Call Of Duty 2<br>
<input type='checkbox' name='games[]' value='COD4MW'> Call Of Duty 4 Modern Warfare<br>
<input type='checkbox' name='games[]' value='CODWAW'> Call Of Duty 5 World At War<br>
<input type='checkbox' name='games[]' value='CODMW2'> Call Of Duty 6 Modern Warfare 2<br>
<input type='checkbox' name='games[]' value='CODBO'> Call Of Duty 7 Black Ops<br>
</td></tr>
<tr><td align='right'><b>Working Microphone?</b><br></td>
<td align='left'><select name ='microphone' value='$microphone'>
<option value=''></option>
<option value='1'>Yes</option>
<option value='0'>No</option>
</select><br></td></tr>
<tr><td align='right'><b>Teamspeak 2?</b><br></td>
<td align='left'><select name ='teamspeak2' value='$teamspeak2'>
<option value=''></option>
<option value='1'>Yes</option>
<option value='0'>No</option>
</select><br></td></tr>
";
mt_srand ((double)microtime()*1000000);
$maxran = 1000000;
$random_num = mt_rand(0, $maxran);
echo "<tr><td colspan='2'>".security_code(array(1,2,3,4,5,6,7,8), 'stacked'); // Closing td and tr must be in security_code() function.
echo "</table><input type='hidden' name='op' value='Apply'>
</td></tr></table>
<input type='submit' name='submit' value='Apply'>
</form></center>";
CloseTable();
include("footer.php");
}
function Apply($realname, $gamename, $email, $gender, $day, $month, $year, $country, $xfire, $teamspeak2, $microphone){
global $db, $prefix, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $gfx_chk, $sitekey, $sitename, $adminmail, $sendmail, $module_name;
include("header.php");
OpenTable();
$match = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_joinus_apps WHERE username='$gamename'"));
if($match > 0){
/* Already Registered Error Message */
echo ("<center><img src=\"images/error.gif\"></center><br>");
echo "<center><br><br><b>Sorry $gamename<br>It appears you have already submitted an application</b><br><br><br></center>";
echo ("<meta http-equiv='refresh' content='3;URL=http://www.yoursite.com/index.php'><br>");
echo ("<center><b>[</b> You Are Being Redirected <b>]</b>");
}else{
$gfx_check = $_POST['gfx_check'];
if (!security_code_check($gfx_check, array(1,2,3,4,5,6,7,8))) {
/* Invalid Security Code Error Message */
echo ("<center><img src=\"images/error.gif\"></center><br>");
echo ('<center><b>Invalid Security Code</b><br><br><br>Please go back and try again</center><br><br>');
echo ('<center>[ <a href="javascript:history.go(-1)">Go Back</a> ]</center>');
CloseTable();
include ("footer.php");
die();
}else{
security_code(array(1,2,3,4,5,6,7,8));
}
if($realname !="" && $gamename !="" && $email !="" && $gender !="" && $day !="" && $month !="" && $year !="" && $country !="" && $xfire !="" && $teamspeak2 !="" && $microphone !=""){
$games = $_POST['games'];
$usergames = "";
for($i=0;$i<count($games);$i++){
if($games[$i]!=""){
$usergames .= "<br>".$games[$i];
}
}
if($usergames !="")
$usergames = substr($usergames,2);
$db->sql_query("INSERT INTO ".$prefix."_joinus_apps VALUES (NULL, '$realname', '$gamename', '$email', '$gender', '$day', '$month', '$year', '$country', '$xfire', '$usergames', '$teamspeak2', '$microphone', now())");
if($sendmail == 1){
$to = $adminmail;
$emailsubject = 'Clan Application';
$message = 'There is a new <b>Clan Application</b> awaiting your attention!!';
$header = "From: $gamename <$email>\n";
$header .= "Reply-To: $email";
mail($to,$emailsubject,$message,$header);
}
/* Success Message */
echo ("<center><img src=\"images/success.gif\"></center><br>");
echo ("<center><b>Your Membership Application has been successfully submitted!</b><br><br><br>");
echo ("<meta http-equiv='refresh' content='5;URL=http://www.yoursite/index.php'><br>");
echo ("<center><b>[</b> You will now be redirected <b>]</b>");
}else{
/* Error Message */
echo ("<center><img src=\"images/error.gif\"></center><br>");
echo ("<center><b>Please Complete All Fields!</b></center><br>");
echo ('<center>[ <a href="javascript:history.go(-1)">Go Back</a> ]</center>');
}
}
CloseTable();
include("footer.php");
}
switch ($op) {
default:
Index();
break;
case "Apply":
Apply($realname, $gamename, $email, $gender, $day, $month, $year, $country, $xfire, $teamspeak2, $microphone);
break;
}
?>
and this file is the part that when i goto my admin panel, shows me who has filled out my application form:
Code: Select all
<?php
if (!defined('ADMIN_FILE')) {
die ("Access Denied");
}
$module_name = "Join_Us";
global $prefix, $db, $admin_file;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT title, admins FROM ".$prefix."_modules WHERE title='Join_Us'"));
$row2 = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM ".$prefix."_authors WHERE aid='$aid'"));
$admins = explode(",", $row['admins']);
$auth_user = 0;
for ($i=0; $i < sizeof($admins); $i++) {
if ($row2['name'] == "$admins[$i]" AND !empty($row['admins'])) {
$auth_user = 1;
}
}
if ($row2['radminsuper'] == 1 || $auth_user == 1) {
function Join_Us() {
global $prefix, $db, $admin_file, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4;
include ("header.php");
OpenTable();
echo"<center><font class='title'><b>Clan Applications</b></font><br><br>";
$rows = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_joinus_apps"));
echo"<table><tr><td>";
if($rows > 0){
echo"<table border='0' cellpadding='3' cellspacing='1' bgcolor=$bgcolor4>";
echo"<tr bgcolor=$bgcolor3><td><b> Applicants Name </b></td><td><b> Application Date </b></td><td><b></b></td></tr>";
$result = $db->sql_query("SELECT * FROM ".$prefix."_joinus_apps ORDER BY date ASC");
while($row = $db->sql_fetchrow($result)){
$appid = $row['aid'];
$gamename = $row['gamename'];
$appdate = $row['date'];
echo"<tr bgcolor=$bgcolor1>
<td><a href=\"".$admin_file.".php?op=Join_Us_Info&appid=$appid\">$gamename</a></td>
<td>$appdate</td>
<td><a href=\"".$admin_file.".php?op=Join_Us_Delete&appid=$appid&ok=0\"><img src=\"images/delete.gif\" alt='Delete' title='Delete' border=\"0\"></a></td></tr>";
}
echo"</table>";
}else{
echo'No New Applications';
}
echo"</td></tr></table>";
CloseTable();
include ("footer.php");
}
function Join_Us_Info($appid) {
global $prefix, $db, $admin_file, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4;
include("header.php");
OpenTable();
$row = $db->sql_fetchrow($db->sql_query("SELECT * FROM ".$prefix."_joinus_apps WHERE aid='$appid'"));
$realname = $row['realname'];
$gamename = $row['gamename'];
$email = $row['email'];
$gender = $row['gender'];
$day = $row['day'];
$month = $row['month'];
$year = $row['year'];
$country = $row['country'];
$xfire = $row['xfire'];
$games = $row['games'];
$microphone = $row['microphone'];
$teamspeak2 = $row['teamspeak2'];
$appdate = $row['date'];
if($gender == 1){
$gender ="Male";
}else{
$gender ="Female";
}
if($teamspeak2 == 1){
$teamspeak2 ="Yes";
}else{
$teamspeak2 ="No";
}
if($microphone == 1){
$microphone ="Yes";
}else{
$microphone ="No";
}
echo"<center><font class='title'><b>Clan Applications</b></font><br><br>
<table cellpadding='3' cellspacing='1' border='0' width='300' bgcolor='$bgcolor4'>
<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Real Name:</b></td>
<td align='left' bgcolor='$bgcolor1'>$realname</td></tr>
<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Gaming Name:</b></td>
<td align='left' bgcolor='$bgcolor1'>$gamename</td>
</tr>
<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>E-Mail:</b></td>
<td align='left' bgcolor='$bgcolor1'><a href='mailto:$email'>$email</a></td>
</tr>
<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Gender:</b></td>
<td align='left' bgcolor='$bgcolor1'>$gender</td>
</tr>
<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Date of Birth:</b></td>
<td align='left' bgcolor='$bgcolor1'>$day-$month-$year</td>
</tr>
<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Country:</b></td>
<td align='left' bgcolor='$bgcolor1'>$country</td>
</tr>
<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Xfire:</b></td>
<td align='left' bgcolor='$bgcolor1'><a href='http://www.xfire.com/profile/$xfire' target='_blank'>$xfire</a></td>
</tr>
<tr><td align='left' valign='top' bgcolor='$bgcolor2' nowrap><b>Games Owned:</b></td>
<td align='left' bgcolor='$bgcolor1'>$games</td>
</tr>
<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Microphone:</b></td>
<td align='left' bgcolor='$bgcolor1'>$microphone</td>
</tr>
<tr><td align='left' bgcolor='$bgcolor2' nowrap><b>Teamspeak 2:</b></td>
<td align='left' bgcolor='$bgcolor1'>$teamspeak2</td>
</tr>";
echo"</table>
<br><br><b>[</b> <a href=\"".$admin_file.".php?op=Join_Us\">Go Back</a> <b>|</b> <a href=\"".$admin_file.".php?op=Join_Us_Delete&appid=$appid&ok=0\">Delete Application</a> <b>]</b>
</center>";
CloseTable();
include("footer.php");
}
function Join_Us_Delete($appid, $ok=0) {
global $prefix, $db, $admin_file;
if ($ok == 1) {
$db->sql_query("delete from ".$prefix."_joinus_apps where aid='$appid'");
Header("Location: ".$admin_file.".php?op=Join_Us");
} else {
include("header.php");
OpenTable();
echo"<center><br><br>Are you sure you want to delete this application?<br><br>"
."[ <a href=\"".$admin_file.".php?op=Join_Us\">"._NO."</a> | <a href=\"".$admin_file.".php?op=Join_Us_Delete&appid=$appid&ok=1\">"._YES."</a> ]</center><br><br>";
CloseTable();
include("footer.php");
}
}
switch ($op) {
case "Join_Us":
Join_Us();
break;
case "Join_Us_Info":
Join_Us_Info($appid);
break;
case "Join_Us_Delete":
Join_Us_Delete($appid, $ok);
break;
}
} else {
include("header.php");
GraphicAdmin();
OpenTable();
echo "<center><b>"._ERROR."</b><br><br>You do not have permission to access this module \"$module_name\"</center>";
CloseTable();
include("footer.php");
}
?>
i suppose i should of posted these scripts in the first place then you would probably been able to see what i was on about, sorry about that sir.
anyways, whats happening is this:
1) when the user fills out the form, the imputted data gets relayed back to my admin section so i can view who has applied and with what credentials.
the 2 parts i'm struggling with is:
the user selects which country they are from by using the dropdown format.
when he/she hits submit, it sends the data to my sql then back to my admin section where i can view what he/she has selected, but it only shows this as 1 and not the country they selected.
2) when the user selects what games they have by putting ticks next to the game title the data that gets sent back to my admin section shows up as again 1 and not the titles that the user has ticked.
i am trying to be clear about what is going on, sorry if this all sounds kuckoo.
but i know what i am on about but it's trying to explain it the best way i know how considering my knowledge of php and databases are very limited.