Jump to content

Archived

This topic is now archived and is closed to further replies.

hexdsl

A little varible problem

Recommended Posts

ok, i am experimenting with PHP to make a basic text RPG, i am quite savvy with other programing languages but sadly not PHP.

the code is a basic setup script for the site, it should simply pass the INPUTBOX entrys to a FlatfileDB handler for writing to a file called ADMIN.DAT (just a txt file really) anyway all it does it pass the NAME of the inbox's tp teh DB handler, i am hopling someone can point out where i am going wrong

CODE:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
<?php
function goninja($adminusr, $adminpswd, $adminemail, $adminloca, $gamename, $gameurl)
{
//Define Table names, for Usability
define('adminusr', 0);
define('adminpswd', 1);
define('adminemail', 2);
define('adminloca', 3);
define('gamename', 4);
define('gameurl', 5);


//Start DataBase Server
require_once('flatfile.php');

//Create New Database Within data directory
$db = new Flatfile();
$db->datadir = 'data/';

//now lets setup first entry
$newpost[adminusr] = $adminusr;
$newpost[adminpswd] = $adminpswd;
$newpost[adminemail] = $adminemail;
$newpost[adminloca] = $adminloca;
$newpost[gamename] = $gamename;
$newpost[gameurl] = $gameurl;
$newId = $db->insertWithAutoId('admin.dat', POST_ID, $newpost);
}
?>

</head>

<body class="thestyle">

<h1 align="center">THE ASCENSION
</h1>
<p align="center" class="thestyle">SOME TEXT HERE</p>
<p align="left" class="thestyle">Well here we go!</p>
<form action="<?php goninja(adminusr, adminpswd, adminemail, adminloca, gamename, gameurl); ?>" method="post" name="form1">
<p> </p>
<table width="535" border="0" align="center">
<tr>
<td width="195"><span class="style4">Admin User Name </span></td>
<td width="330"><input name="adminusr" type="text" id="adminusr" size="50" maxlength="50"></td>
</tr>
<tr>
<td><span class="style4">Admin Password</span></td>
<td><input name="adminpswd" type="text" id="adminpswd" size="50" maxlength="50"></td>
</tr>
<tr>
<td><span class="style4">Admin E-mail address</span></td>
<td><input name="adminemail" type="text" id="adminemail" size="50" maxlength="50"></td>
</tr>
<tr>
<td><span class="style4">Admin Geo-Location</span></td>
<td><input name="adminloca" type="text" id="adminloca" size="50" maxlength="50"></td>
</tr>
<tr>
<td><span class="style4">Game Name </span></td>
<td><input name="gamename" type="text" id="gamename" size="50" maxlength="50"></td>
</tr>
<tr>
<td height="34"><span class="style4">Game URL </span></td>
<td><input name="gameurl" type="text" id="gameurl" size="50" maxlength="50"></td>
</tr>
</table>
<p align="center">
<input type="submit" name="Submit" value="Submit">[/quote]

Share this post


Link to post
Share on other sites
I think its the way you handle the form. Just set the form action to the same page that you are or and then add this at the top:

[code]<?php
if(isset($_POST['Submit'])) {
    goninja($_POST['adminusr'], $_POST['adminpswd'], $_POST['adminemail'], $_POST['adminloca'], $_POST['gamename'], $_POST['gameurl']);
}
?>[/code]

That should work. I would also recommend changing:

[code]$newpost[adminusr][/code]

To this:

[code]$newpost['adminusr'][/code]

For all of the $newpost array.

Share this post


Link to post
Share on other sites

×

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.