PDA

View Full Version : A bit of help?



Johno
07-07-2008, 02:26 PM
Hey,

I haven't coded in a while but since I am working on my new fansite I am trying to do some form of coding for it.

Anyway, the page: http://www.studiohabbo.net/pages/test.phps (Its a .phps so you can see the code - Running version is at the same url only .php) does not work right.

I get "Parse error: syntax error, unexpected T_ELSE in /home/sh/public_html/pages/test.php on line 39"

Undoubtedly, I'm probably doing something very stupid but I cant seem to see whats wrong.

I know my code isn't very clean, any ideas what is up?

Decode
07-07-2008, 03:06 PM
Try this :)



<?php

/**
* @author StudioHabbo.NET
* @copyright 2008
*/

include_once '../includes/php/config.php';

if ($_POST[submit]) {
// Checks to see if the form has been submitted
$username = $_POST[username];
$habboname = $_POST[habboname];
$position = $_POST[position];

if($username==NULL|$habboname==NULL|$position==NUL L) {
//Checks inputs to see if any fields were left blank
echo "A field was left blank.";
}
else{
$checkname = mysql_query("SELECT username FROM stafflist WHERE username='$username'");
$checkname= mysql_num_rows($checkname);
$checkhname = mysql_query("SELECT habboname FROM stafflist WHERE habboname='$habboname'");
$checkhname = mysql_num_rows($checkhname);
if ($checkemail>0|$checkname>0) {
// Whoops, This person is already on the staff list!
echo "This user is already on the staff list!";
}
else{
// Not on the staff list, So we continue
$username = htmlspecialchars($username);
$habboname = htmlspecialchars($habboname);
$position = htmlspecialchars($position);
// Checks for HTML, If there is any it gets rid of it!
// Everything seems good, lets insert into the database
$query = mysql_query("INSERT INTO stafflist (username, habboname, password) VALUES('$username','$habboname','$position')");
// Everything is inserted!
echo "$habboname has been added to the staff list!";
}
}
}
else
{
// the form has not been submitted...so now we display it.
?>
<span class="style1">Add User to Staff List<br />
</span>
<span class="style3"><em>Submit an existing user to the Staff List</em></span>
<form method="POST">
<table width="298" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="133" class="style3">SH Username:</td>
<td width="202"><span class="style3">
<input type="text" maxlength="30" name="username" />
</span></td>
</tr>
<tr>
<td height="23" class="style3">Habbo Name:</td>
<td><span class="style3">
<input name="habboname" type="text" id="habboname" maxlength="20" />
</span></td>
</tr>
<tr>
<td class="style3">Position:</td>
<td><span class="style3">
<input name="position" type="text" id="position" maxlength="25" />
</span></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td><input name="submit" type="submit" id="submit" value="Submit" /></td>
<td>&nbsp;</td>
</tr>
</table>
</form>
<?php
}
?>


Its best to tab your code, as its easyer to find errors.

Johno
07-07-2008, 05:44 PM
Thanks :)

Works now +Rep

Want to hide these adverts? Register an account for free!