Connecting Tech Pros Worldwide Forums | Help | Site Map

Php Form Validation

Member
 
Join Date: Sep 2006
Location: Atlanta, Ga
Posts: 41
#1: Apr 11 '07
I found this form on the scripts. However when I attemp to open the php file on the sever I get a error message Parse error: syntax error, unexpected $end on line 238
[PHP]<?
/**
* Main.php
*
* This is an example of the main page of a website. Here
* users will be able to login. However, like on most sites
* the login form doesn't just have to be on the main page,
* but re-appear on subsequent pages, depending on whether
* the user has logged in or not.
*
* Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
* Last Updated: August 26, 2004
*/
include("include/session.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<style>
body {
margin-top: 0px;
color: #cccccc;
font-family: Verdana, Helvetica, Arial, sans-serif;
font-size: 10px;
font-weight: normal;
letter-spacing: 0px;
word-spacing: 0px;
background-color: #ffffff;
}
#content {
color: #cccccc;
font-family: Verdana, Helvetica, Arial, sans-serif;
font-size: 10px;
font-weight: normal;
letter-spacing: 0px;
word-spacing: 0px;
border-left: 1px #cccccc solid;
border-right: 1px #cccccc solid;
border-bottom: 1px #cccccc solid;
}
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>FORM1</title>
</head>
<?
/**
* User has already logged in, so display relavent links, including
* a link to the admin center if the user is an administrator.
*/
if($session->logged_in){
echo"
<body>
<table width=\"500\" border=\"0\" align=\"center\" cellpadding=\"0\"
cellspacing=\"0\">
<tr>
<td align=\"center\">
<?php
// Connect to database
$usr = 'xxxxxx';
$pwd = 'xxxxxx';
$db = 'xxxxxx';
$host = 'localhost';

# connect to database
$cid = mysql_connect($host,$usr,$pwd);
mysql_select_db($db);
if (mysql_error()) { print 'Database ERROR: ' . mysql_error(); }

##### Check if form was Submitted #####
if($_POST[mode]== add ){
### Retrieve the variables ###
if($_POST[firstname] =='' ){
$error = '* Please fill in First Name #1<br>';
}else{
$firstname = $_POST[firstname];
}
if($_POST[lastname] == ''){
$error .= '* Please fill in Last Name #2<br>';
}else{
$lastname = $_POST[lastname];
}
if($_POST[phonenumber] == ''){
$error .= '* Please fill in Phone Number #2<br>';
}else{
$phonenumber = $_POST[phonenumber];
}
if($_POST[state] == ''){
$error .= '* Please fill in Last State #2<br>';
}else{
$state = $_POST[state];
}
if($_POST[category] == ''){
$error .= '* Please fill in Category #2<br>';
}else{
$category = $_POST[category];
}
if($_POST[artistname] == ''){
$error .= '* Please fill in Artist Name #2<br>';
}else{
$artistname = $_POST[artistname];
}
if($_POST[tracktitle] == ''){
$error .= '* Please fill in Track Title #2<br>';
}else{
$tracktitle = $_POST[tracktitle];
}
if($_FILES[file][name] == ''){
$error .= '* Please select a File to upload<br>';
}else{
$file_name = $_FILES[file][name];
/* Process file*/
}
### If fields are valid then attempt an insert ###
### If not set $error and bypass the insert ###
if(!isset($error)){
$insert = 'INSERT INTO $talent(firstname, lastname, phonenumber, state, category, artistname, tracktitle, $username) values (
'$firstname',
'$lastname',
'$phonenumber',
'$email',
'$state',
'$category',
'$artistname',
'$tracktitle',
'$state',
'$category',
'$file_name'
'$username',)';
if(!$result = mysql_query($insert)){
$error .= 'Error in inserting<br>';
}else{ ### If insert goes well, redirect to another page ###
?>
<script language=\"JavaScript\">
<!--
self.location='<?php echo 'confirmation.php';?>'
//-->
</script>
<?
}//if(!isset($error)){
### If there was an error display it ###
if(isset($error)){
echo '<table width=\"300\" border=\"0\" cellspacing=\"0\"
cellpadding=\"0\">';
echo '<tr>';
echo '<td bgcolor=\"#FF0000\">'.$error.'</td>';
echo '</tr>';
echo '</table>';
}
}//if($_POST[mode] == add){
?>
<form action=\". '$HTTP_SERVER_VARS[PHP_SELF]'.\"
method=\"post\" enctype=\"multipart/form-data\" name=\"add_fields\"
id=\"add_fields\">
<table width=\"350\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"content\">
<tr>
<td width=\"120\" align=\"left\">First Name: </td>
<td width=\"130\" align=\"right\"><input name=\"firstname\" type=\"text\" id=\"firstname\" value=\"<?php
echo $firstname;?>\"></td>
</tr>
<tr>
<td width=\"120\" align=\"left\">Last Name: </td>
<td width=\"130\"align=\"right\"><input name=\"lastname\" type=\"text\" id=\"lastname\" value=\"<?php
echo $lastname;?>\"></td>
</tr>
<tr>
<td width=\"120\" align=\"left\">Phone Number: </td>
<td width=\"130\"align=\"right\"><input name=\"phonenumber\" type=\"text\" id=\"phonenumber\" value=\"<?php
echo $phonenumber;?>\"></td>
</tr>
<tr>
<td width=\"120\" align=\"left\">State: </td>
<td width=\"130\"align=\"right\"><input name=\"state\" type=\"text\" id=\"state\" value=\"<?php
echo $state;?>\"></td>
</tr>
<tr>
<td width=\"120\" align=\"left\">Category: </td>
<td width=\"130\"align=\"right\"><input name=\"category\" type=\"text\" id=\"category\" value=\"<?php
echo $category;?>\"></td>
</tr>
<tr>
<td width=\"120\" align=\"left\">Artist Name: </td>
<td width=\"130\"align=\"right\"><input name=\"artistname\" type=\"text\" id=\"artistname\" value=\"<?php
echo $artistname;?>\"></td>
</tr>
<tr>
<td width=\"120\" align=\"left\">Track Title: </td>
<td width=\"130\"align=\"right\"><input name=\"tracktitle\" type=\"text\" id=\"tracktitle\" value=\"<?php
echo $tracktitle;?>\"></td>
</tr>
<tr>
<td width=\"120\" align=\"left\">Audio Upload: </td>
<td width=\"130\" align=\"right\"><input type=\"file\" name=\"file\">
<br><?php echo $file_name;?></td>
</tr>
<tr align=\"center\">
<td colspan=\"2\"><input type=\"submit\" name=\"Submit\"
value=\"Submit\">
<input type=\"reset\" name=\"Submit2\" value=\"Cancel\"
onClick=\"self.location='redirect.php'\">
<input name=\"mode\" type=\"hidden\" id=\"mode\" value=\"add\"> </td>
</tr>
</table>
</form></td>
</tr>
</table>
';
else{
/**
* User not logged in, display the login form.
* If user has already tried to login, but errors were
* found, display the total number of errors.
* If errors occurred, they will be displayed.
*/
if($form->num_errors > 0){
echo '<font size=\"2\" color=\"#ff0000\">'.$form->num_errors.' error(s) found</font>';
}
?>

<table width=\"310\">
<tr>
<td><img src=\"http://www.atlantasundergroundhitsecommerce.com/ATL_version2/Login_System_v.2.0/Login_System_v.2.1/images/audioload.gif \" width=\"340\" height=\"180\" border=\"1\" alt=\"fast track with atl hits\"></td>
</tr>
</table>
<form action=\"process.php\" method=\"POST\">
<table align=\"left\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" class=\"T1\">
<tr><td>Username:</td><td><input type=\"text\" name=\"user\" maxlength=\"30\" value=\"<? echo $form->value('user'); ?>\"></td><td><? echo $form->error('user'); ?></td></tr>
<tr><td>Password:</td><td><input type=\"password\" name=\"pass\" maxlength=\"30\" value=\"<? echo $form->value('pass'); ?>\"></td><td><? echo $form->error('pass'); ?></td></tr>
<tr><td colspan=\"2\" align=\"left\"><input type=\"checkbox\" name=\"remember\" <? if($form->value('remember') != ''){ echo 'checked'; } ?>>
<font size=\"2\">Remember me next time &nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"hidden\" name=\"sublogin\" value=\"1\">
<input type=\"submit\" value=\"Login\"></td></tr>
<tr><td colspan=\"2\" align=\"left\"><br><font size=\"2\">[<a class=\"T1\" href=\"forgotpass.php\">Forgot Password?</a>]</font></td><td align=\"right\"></td></tr>
<tr><td colspan=\"2\" align=\"left\"><br>Not registered? <a class=\"T1\" href=\"register.php\">Sign-Up!</a></td></tr>
</table>
</form>[/PHP]
I played around with it for a few days any insight would be great...

code green's Avatar
Expert
 
Join Date: Mar 2007
Location: England
Posts: 1,083
#2: Apr 11 '07

re: Php Form Validation


There is a php brace <? or ?> out of place or a bracket { or } too many or missing
Member
 
Join Date: Sep 2006
Location: Atlanta, Ga
Posts: 41
#3: Apr 11 '07

re: Php Form Validation


Thanks, I will take a look latter today for this issue!
cassbiz's Avatar
Familiar Sight
 
Join Date: Oct 2006
Location: Florida
Posts: 204
#4: Apr 11 '07

re: Php Form Validation


Quote:

Originally Posted by underground

Thanks, I will take a look latter today for this issue!

Take a look at line 238 or any of the lines prior to it.
Reply