Jump to content

[SOLVED] Really dont know the subject of this....


onthespot

Recommended Posts

Ok so i have a form that when processed has action ="". Therefore it is coming back to the same page.

 

The code:

<?php

 

$user=$_POST['awarduser'];

$comment=$_POST['awardcomment'];

$type=$_POST['awardtype'];

 

 

$query="INSERT INTO ".TBL_AWARDS." VALUES (NULL, '$type','$user', now(), '$comment')";

 

if(!$comment || strlen($comment = trim($comment)) == 0)

    echo "Comment not entered";

else if(!$comment || strlen($comment = trim($comment)) < 10)

    echo "Comment too short, must be 10 characters at least";

else if (!$comment || strlen($comment = trim($comment)) > 10){

    echo "".$_SESSION['username'].", you have added an award to ".$_POST['awarduser']."'s Profile. ";

  mysql_query($query);}

 

?>

 

 

<h4>Award player</h4>

<form action="" method="POST">

Type:<select name="awardtype">

<option value="league1">League winner</option>

<option value="league2">League runner up</option>

<option value="league3">Leauge 3rd/play off winner</option>

</select>

Award: <select name="awarduser">

<?php

    $res=mysql_query("SELECT username FROM ".TBL_USERS."") or die(mysql_error());

  while($row=mysql_fetch_assoc($res)){

    $username=htmlspecialchars($row['username']);

    echo "<option value=\"$username\">$username</option>";

  }

?>

</select>

Comment:<textarea name="awardcomment" rows="2" cols="30" ></textarea>

<div align="right"><input type="submit" name="submit" value="Award Player"></div>

</form>

 

The problem is, the comment not entered comes up as soon as i load the page, as there is no comment entered. Whats the best way around this that enables the form and processing to be done on the same page? thanks

Archived

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

×
×
  • Create New...

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.