View Single Post
  #1 (permalink)  
Old 02-12-2008, 11:22 PM
jinchiruki jinchiruki is offline
WebProWorld New Member
 
Join Date: Feb 2008
Posts: 3
jinchiruki RepRank 0
Unhappy pls solve myproblemo

Index.php


<table width="1000" height="95" border="1">
<tr>
<td bgcolor="#0000FF">&nbsp;</td>
</tr>
</table>
<p>


<center><a href="register.html">Click here for register</a><br>
<br>


<p>
<b> <html> Attend List; </b><p>
<?php


include("connect.php");

$query="SELECT * FROM rsvp ";
$result=mysql_query($query);
$num = mysql_num_rows ($result);
mysql_close();

if ($num > 0 )

{
$i=0;
while ($i < $num)


{
$name = mysql_result($result,$i,"name");
$email = mysql_result($result,$i,"email");
$contact = mysql_result($result,$i,"contact");
$person_attend = mysql_result($result,$i,"person_attend");
$comment = mysql_result($result,$i,"comment");
$id = mysql_result($result,$i,"id");

echo "<b>Name:</b> $name<br>";
echo "<b>Email:</b> $email<br>";
echo "<b>Contact:</b> $contact<br>";
echo "<b>Person attend:</b> $person_attend<br>";
echo "<b>Comment:</b> $comment<br>";

echo "<br><br>";

++$i; }


} else { echo "No one yet register"; }
?>
</center>




register.html


<table width="1000" height="95" border="1">
<tr>
<td bgcolor="#0000FF">&nbsp;</td>
</tr>
</table>



<html>
<center>
<head>
<title></title>

</head>
<body>
<form id="FormName" action="added.php" method="post" name="FormName">

<table width="416" height="386" border="0" cellpadding="2" cellspacing="2">
<tr>
<td width="145" height="26" align="right">Name</td>

<td width="257"><input id="name" name="name" type="text" size="25" value="" maxlength="50" /></td>
</tr>
<tr></tr>
<tr>
<td align="right">Email</td>
<td><input id="email" name="email" type="text" size="25" value="" maxlength="50"></td>
</tr>

<tr>
<td align="right">Phone</td>
<td><input id="contact" name="contact" type="int" size="25" value="" maxlength="10"></td>
</tr>
<tr>
<td align="right">Person attend</td>
<td><textarea id="person_attend" name="person_attend" rows="4" cols="40"></textarea></td>
</tr>
<tr>
<td align="right">Comment</td>
<td><textarea id="comment" name="comment" rows="4" cols="40">
</textarea></td>
</tr>
<tr>

<td> </td>
</tr>
<tr>
<td align="right"></td>
<td><p>
<input type="submit" value="Submit">
<INPUT name="RESET" TYPE="RESET" VALUE="Reset">


</tr>
</table>
</form>


<P>&nbsp;</P>
</body>
</center>
</html>






added.php




<table width="1000" height="95" border="1">
<tr>
<td bgcolor="#0000FF">&nbsp;</td>
</tr>
</table>



<?
include("connect.php");

//this is your validation in the form,put it here....



if (empty($_POST['name']))

{

$errors[] = 'Please enter a name';

}







if (empty($_POST['email']))

{

$errors[] = 'Please enter an e-mail';

}

else if (!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $_POST['email']))

{

$errors[] = 'Please enter a valid e-mail address';

}





if (empty($_POST['contact']))

{

$errors[] = 'Please enter a contact';

}

else if (!is_numeric($_POST['contact']))

{

$errors[] = 'Please enter a valid contact with a numeric value';

}





if (empty($_POST['person_attend']))

{

$errors[] = 'Please enter some word';

}

else if (strlen ($_POST['person_attend']) > 255)

{

$errors[] = '';









if (empty($_POST['comment']))

{

$errors[] = 'Please enter some comment';

}

else if (strlen ($_POST['comment']) > 255)

{

$errors[] = ' ';

if (count($errors) > 0)

{

die(echo $errors[0];



}

else

{

//process form




//this is your add query....

$name = $_POST['name'];

$email = $_POST['email'];

$contact = $_POST['contact'];

$person_attend = $_POST['person_attend'];

$comment = $_POST['comment'];





$query = "INSERT INTO rsvp (id, name, email, contact, person_attend, comment)

VALUES ('', '$name', '$email', '$contact', '$person_attend', '$comment')";



$results = mysql_query($query) or die

("Could not execute query : $query." . mysql_error());





{

echo "thanks you ";

}

mysql_close();

}

?>

<br>
<a href="Index.php">View list attend</a>




connect.php


<?php
define('DB_HOST' , 'localhost');
define('DB_NAME' , 'rsvp');
define('DB_USERNAME' , 'root');
define('DB_PASSWORD' , '');

$conn = mysql_connect(DB_HOST, DB_USERNAME )
or die(mysql_error());mysql_select_db(DB_NAME);
?>
can somebody help me fix this?

Last edited by jinchiruki; 02-12-2008 at 11:26 PM.
Reply With Quote