Jump to content

[SOLVED] what wrong there no error messages


nelquintin

Recommended Posts

please help i have encoded the "id" from another script and want to insert it in the id column in another table.here my code.

<?

if  (isset($_POST["event_desc"])) { $event_desc = $_POST['event_desc']; }

if  (isset($_POST["submit"]) && (!isset($_POST["event_desc"]) or empty($event_desc) ))

{ ?>

<script language="Javascript" type="text/javascript">

<!--

        window.open('empty.html', '_myevent', 'HEIGHT=100,resizable=yes,WIDTH=400');

 

//-->

</script>

<?

}

if ( isset($_POST["submit"]) && !empty($event_desc)) {

  $eventyear = $_POST['eventyear'];

  $eventmonth = $_POST['eventmonth'];

  $eventdate = $_POST['eventdate'];

  $id = $_GET['id'];

  $day_in_a_mth = date('t', mktime(0, 0, 0, $eventmonth, 1, $eventyear)) ;

 

if ($day_in_a_mth >= $eventdate )

  {

  $fulldate = $eventyear."-".$eventmonth."-".$eventdate;

  $event_desc = $_POST['event_desc'];

  $id = $_GET['id'];

  $sql = "INSERT INTO event SET date='$fulldate', event_desc='$event_desc', id='$id'";

  $query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());

  message( "ADD EVENT", "DATA ENTERED");  }

else {

  message( "ERROR", "DATE ENTERED NOT VALID");

 

  }

}

else {

?>

<?

$id=$_GET['id'];

$query="SELECT * FROM client WHERE id='$id'";

$result=mysql_query($query);

$num=mysql_num_rows($result);

$i=0;

while ($i < $num) {

$name=mysql_result($result,$i,"name");

$surname=mysql_result($result,$i,"surname");

$username=mysql_result($result,$i,"username");

?>

 

Link to comment
Share on other sites

Hi,

 

It looks like your problem is caused by mixing the use of $_GET and $_POST. Assuming that the form has been posted, the $_GET array will be empty and as a result your id will also be empty.

 

Now, I don't know how you display your form, but let's say you have a file named showform.php and the URL contains the ID that you wish to eventually insert into your database. The form would be displayed by visiting the URL showform.php?id=xyz.

 

You can then add a hidden input field to your form named "id" with the value passed in as the value of $_GET['id'], as follows:

<form action="processform.php" method="POST">

<input type="hidden" name="id" value="<?php echo $_GET['id']; ?>">

... rest of form here ...

</form>

 

Now, in the code you posted (which I refer to as processform.php), replace the $_GET['id'] with $_POST['id'] and things should start to improve for you.

 

Regards,

Darren.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.