Debt Consolidation - Find jobs - Free Animated Greetings - Debt Consolidation - French Property

PDA

View Full Version : Nothing appear


davenet
Apr 7th 2007, 8:26 am
The following codes does not work. Nothing appear on the screen whenever I run the code, why?



<?
include ("server.php");
include ("menu.php");

echo "

<h1 align=\"center\">Input Nilai Mahasiswa</h1>
<form method=\"post\" action=\"$PHP_SELF\">
<h3 align=\"center\">$nim</h3>

<table border=\"0\" align=\"center\">
<tr>
<td>Nim</td>
<td>
<select onchange=\"this.form.submit()\">";

$koneksi = mysql_connect($host, $user, $pass) or die (mysql_error());
mysql_select_db($db) or die (mysql_error());

<option value=\"kosong\">::::Nim::::</option>";
while ($row = mysql_fetch_array($query))
{

// $row[0] = nim
// $nim diperoleh jika tag select di scroll

if ($nim==$row[0])
echo "<option value = \"$row[0]\" selected>$row[0] </option>";
else
{
echo "<option value = \"$row[0]\">$row[0]</option>";
}
}

echo "</select></td></tr>";

$query_mhs =
mysql_query("select mhs.nim, mhs.nama, mhs.jk, mhs.nilai, mhs.grade, mhs.foto, jurusan.nama_jurusan from mhs, jurusan where mhs.jurusan=jurusan.kode_jurusan and nim='$nim' order by nim", $koneksi) or die (mysql_error());

$row_mhs = mysql_fetch_array($query_mhs);

/*
$row_mhs[0] = nim
$row_mhs[1] = nama
$row_mhs[2] = jk
$row_mhs[3] = nilai
$row_mhs[4] = grade
$row_mhs[5] = foto
$row_mhs[6] = jurusan
*/

echo "
<tr>
<td>Nama</td>
<td>$row_mhs[1]</td>
</tr>";

echo "<tr>
<td>Nilai</td>
<td>
<input type=\"text\" name=\"nilai\">
</td>
</tr>";

echo "<tr>";

echo "
<td>Jurusan</td>
<td>$row_mhs[6]</td></tr>";

echo "
<tr>
<td>
<input type=\"submit\" name=\"kirim\" value=\"kirim\" >
</td>
</tr>";

echo "</table>";
echo "<img src=\"../image/$row_mhs[5]\" alt=\"$row_mhs[1]\" align=\"center\">

</form>";

if ($kirim)
{
if ($nilai>="80")
$grade = "A";
else if (($nilai >= "70") and ($nilai <= "79"))
$grade = "B";
else if (($nilai >= "60") and ($nilai <= "69"))
$grade = "C";
else if (($nilai >= "50") and ($nilai <= "59"))
$grade = "D";
else if ($nilai < "50")
$grade = "E";

$query_update = mysql_query ("update mhs set nilai='$nilai', grade='$grade' where nim='$nim'", $koneksi) or die (mysql_error());
}

?>


Appreciate comments. :)

nico_swd
Apr 7th 2007, 8:43 am
First, try replacing the short PHP tags with the standard ones. (<?php). They might be disabled by the host and your code won't be parsed.

Then try setting this right under the PHP tags if the above doesn't work.

error_reporting(E_ALL);
ini_set('display_errors', '1');

davenet
Apr 7th 2007, 10:02 pm
I have replaced the previous code with this:



<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');

include ("server.php");
include ("menu.php");

echo "

<h1 align=\"center\">Input Nilai Mahasiswa</h1>
<form method=\"post\" action=\"$PHP_SELF\">
<h3 align=\"center\">$nim</h3>

<table border=\"0\" align=\"center\">
<tr>
<td>Nim</td>
<td>
<select onchange=\"this.form.submit()\">";

$koneksi = mysql_connect($host, $user, $pass) or die (mysql_error());
mysql_select_db($db) or die (mysql_error());

<option value=\"kosong\">::::Nim::::</option>";
while ($row = mysql_fetch_array($query))
{

// $row[0] = nim
// $nim diperoleh jika tag select di scroll

if ($nim==$row[0])
echo "<option value = \"$row[0]\" selected>$row[0] </option>";
else
{
echo "<option value = \"$row[0]\">$row[0]</option>";
}
}

echo "</select></td></tr>";

$query_mhs =
mysql_query("select mhs.nim, mhs.nama, mhs.jk, mhs.nilai, mhs.grade, mhs.foto, jurusan.nama_jurusan from mhs, jurusan where mhs.jurusan=jurusan.kode_jurusan and nim='$nim' order by nim", $koneksi) or die (mysql_error());

$row_mhs = mysql_fetch_array($query_mhs);

/*
$row_mhs[0] = nim
$row_mhs[1] = nama
$row_mhs[2] = jk
$row_mhs[3] = nilai
$row_mhs[4] = grade
$row_mhs[5] = foto
$row_mhs[6] = jurusan
*/

echo "
<tr>
<td>Nama</td>
<td>$row_mhs[1]</td>
</tr>";

echo "<tr>
<td>Nilai</td>
<td>
<input type=\"text\" name=\"nilai\">
</td>
</tr>";

echo "<tr>";

echo "
<td>Jurusan</td>
<td>$row_mhs[6]</td></tr>";

echo "
<tr>
<td>
<input type=\"submit\" name=\"kirim\" value=\"kirim\" >
</td>
</tr>";

echo "</table>";
echo "<img src=\"../image/$row_mhs[5]\" alt=\"$row_mhs[1]\" align=\"center\">

</form>";

if ($kirim)
{
if ($nilai>="80")
$grade = "A";
else if (($nilai >= "70") and ($nilai <= "79"))
$grade = "B";
else if (($nilai >= "60") and ($nilai <= "69"))
$grade = "C";
else if (($nilai >= "50") and ($nilai <= "59"))
$grade = "D";
else if ($nilai < "50")
$grade = "E";

$query_update = mysql_query ("update mhs set nilai='$nilai', grade='$grade' where nim='$nim'", $koneksi) or die (mysql_error());
}

?>



For additional information, I also have the following tables on my sql server:

------------------------------------------------------------

CREATE TABLE 'jurusan' (
'kode_jurusan' char(3) NOT NULL default '',
'nama_jurusan' char(25) NOT NULL default '',
PRIMARY KEY ('kode_jurusan')
) TYPE=MyISAM;

CREATE TABLE 'mhs' (
'nim' char(10) NOT NULL default '',
'nama' char(25) NOT NULL default '',
'jk' enum ('1', '0') NOT NULL default '0',
'nilai' int(3) NOT NULL default '0',
'grade' char(1) NOT NULL default '',
'jurusan' char(3) NOT NULL default '',
'foto' char(15) default NULL,
PRIMARY KEY ('nim')
) TYPE=MyISAM;

-------------------------------------------------------

The result is still the same. any more ideas?

Rub3X
Apr 7th 2007, 10:17 pm
Try to control F5 which will refresh without cache. Also view source and see if there is anything there. If error reporting is on, it has to error. And from your code - there should definitely be text echod.

sea otter
Apr 7th 2007, 11:42 pm
line 24, change this

<option value=\"kosong\">::::Nim::::</option>";


to this

echo "<option value=\"kosong\">::::Nim::::</option>";


After doing that, the code passes the php lint syntax checker (from the command line: php -l scriptname) Note that the parameter is "minus el".

davenet
Apr 8th 2007, 8:34 pm
Thanks all. Now, I get the following output:


Notice: Undefined variable: PHP_SELF in /home/davenet/public_html/php/input_nilai_mhs.php on line 12

Notice: Undefined variable: nim in /home/davenet/public_html/php/input_nilai_mhs.php on line 13

Input Nilai Mahasiswa
Nim ::::Nim:::: Notice: Undefined variable: query in /home/davenet/public_html/php/input_nilai_mhs.php on line 25 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/davenet/public_html/php/input_nilai_mhs.php on line 25

Notice: Undefined variable: nim in /home/davenet/public_html/php/input_nilai_mhs.php on line 42
Nama
Nilai
Jurusan



Notice: Undefined variable: kirim in /home/davenet/public_html/php/input_nilai_mhs.php on line 88


Can anyone suggest how to fix the errors?

Rub3X
Apr 8th 2007, 8:59 pm
Notices mean nothing, they're appearing cause of E_ALL

sea otter
Apr 8th 2007, 9:06 pm
Notices are quite significant indeed, especially in the case of the ones we have here.

PHP_SELF isn't a variable; it's an entry in the $_SERVER array, and so must be referred to as $_SERVER['PHP_SELF'];

Change line 12 from this

<form method=\"post\" action=\"$PHP_SELF\">

to this

<form method=\"post\" action=\"{$_SERVER['PHP_SELF']}\">


As for the next error RE $nim, you're using a variable that has not been declared or initialized anywhere. Obviously, you intend for it to have some value, so the question is, where do you set it (or where did you mean to set it? In server.php? In menu.php?

Same goes for the variable $kirim. Where did you mean to set it?

Let's start with those.

jitesh
Apr 9th 2007, 6:08 am
echo "<option value=\"kosong\">::::Nim::::</option>";

TwistMyArm
Apr 9th 2007, 6:28 am
echo "<option value=\"kosong\">::::Nim::::</option>";

No offence jitesh, but do you EVER read the threads that you reply to? You seem to have a habit of just jumping in to threads late with replies that have been made a long time before you got there.

Would it hurt you to read what's already been written or maybe ask for you to CONTRIBUTE to the discussion as opposed to just apparently parroting other people?

I know that I'm not contributing myself to this thread but man... it needs to be said!

Oh, and major apologies to davenet for just 'semi-hijacking' his thread. If it helps, I would suggest that your code seems to assume that register_globals is on. I would check to see if it's been turned off and if so, either turn it on or rewrite your code to assume it's not on. I strongly recommend the latter for two reasons: 1) it's a lot more secure; and 2) register_globals is being dropped eventually, anyway, so you may as well get used to writing the code now.

nico_swd
Apr 9th 2007, 6:44 am
Notices are quite significant indeed

True. Professionally written code should not leave any E_NOTICES or warnings. Not even if error reporting is set to E_ALL. Each time a notice or warning appears, it's written to the error log, which means, open file, write, close. So your code executes slower. It should check for all possible errors and deal with them before they have a chance to appear.

davenet
Apr 12th 2007, 3:20 am
As for the next error RE $nim, you're using a variable that has not been declared or initialized anywhere. Obviously, you intend for it to have some value, so the question is, where do you set it (or where did you mean to set it? In server.php? In menu.php?

Same goes for the variable $kirim. Where did you mean to set it?

Let's start with those.



menu.php basically shows me links of other forms where one of them I input $nim:

input_data_mhs.php


<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

include ("server.php");
include ("menu.php");

echo "
<h1 align=\"center\">Input Data Mahasiswa</h1>
<form method=\"post\" action=\"input_data.php\" ENCTYPE=\"MULTIPART/FORM-DATA\">

<table border=\"0\" align=\"center\">
<tr>
<td>Nim</td>
<td><input type=\"text\" name=\"nim\"></td>
</tr>
<tr>
<td>Nama</td>
<td><input type=\"text\" name=\"nama\"></td>
</tr>";

echo "
<tr>
<td>Jenis Kelamin</td>
<td><input type=\"radio\" name=\"jk\" value\"1\">Laki</td>
</tr>

<tr>
<td></td>
<td><input type=\"radio\" name=\"jk\" value=\"0\">Perempuan</td>
</tr>";


echo "
<tr>
<td>Angkatan</td>
<td><select name=\"angkatan\">
<option value=\"kosong\"> Tahun </option>";
$tahun = (integer) date ("Y");
for ($i = $tahun; $i>($tahun - 6); $i--)
{
echo "<option value=\"$i\">$i";
}
echo "</option>
</select><td></tr>";
echo "
<tr>
<td>Jurusan</td>
<td><select name=\"jurusan\">
<option value=\"kosong\">---Program Studi---
</option>";

$koneksi = mysql_connect($host, $user, $pass) or die (mysql_error());
mysql_select_db($db, $koneksi) or die (mysql_error());
$query = mysql_query("select * from jurusan order by kode_jurusan", $koneksi) or die (mysql_error());

while ($row_nim = mysql_fetch_array($query))
{
echo "<option value = \"$row_nim[0]\" > $row_nim[1]
</option>";
}
echo "</td>";
echo "
<tr>
<td>Foto</td>
<td><input type=\"FILE\" accept=image/jpeg name=\"foto\"></td></tr>";

echo "
<tr>
<td><input type=\"submit\" value=\"submit\"></td>
<td><input type=\"reset\" value=\"reset\"></td>
</tr>

</table>
";

?>


After I type in the form in input_data_mhs.php then it will execute:

input_data.php


<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

include ("server.php");

// kata yang di ucwords() akan mempunyai huruf pertamanya
// huruf kapital
// walaupun sengaja di tulis dalam huruf kecil

$nama = ucwords($nama);

$koneksi = mysql_connect ($host, $user, $pass)
or die (mysql_error());
mysql_select_db($db) or die (mysql_error());

// Copy file ke dalam folder ../image

copy ($foto, "../image/$foto_name");

// Karena hanya memasukkan informasi mahasiswa maka
// untuk pengisian nilai dan grade di buatkan form tersendiri
// sehingga pada file ini dikosongi

mysql_query ("insert into mhs values ('', '$nim', '$nama', '$jk', '', '', '$jurusan', '$foto_name')", $koneksi)
or die (mysql_error());

include ("menu.php");

?>

$nama = ucwords($nama);



and it shows me this result:

Column count doesn't match value count at row 1

and the same errors still appears in input_nilai_mhs.php, which is $nim and $kirim. $kirim basically is a button to send the form information to the database.

and I have this code in server.php


<?
$host = "localhost";
$user = "davenet_davenet";
$pass = "******";
$db = "davenet_php";
?>

davenet
Apr 17th 2007, 1:26 am
What does this error means?

Column count doesn't match value count at row 1

Any help?

sea otter
Apr 17th 2007, 10:33 am
It means the number of items in your INSERT statement doesn't match the number of items in your database table, and/or the parameters in your VALUE clause do not match the order in which the parameters are declared in your table.

Basically, you're trying to asign a value that isn't an empty string to an auto-incremented field (typically called 'id').

Try using the more detailed INSERT syntax which explicitly names the columns, and make sure the arguments in VALUES are in the same order, e.g.

INSERT into mhs ('id', 'col_name2', 'col_name3') VALUES ('','val2','val3');


Note that 'id' gets an empty string as a value, so that it is allowed to autoincrement on the insert (if your autoincrement column is named something else, use the correct name).

davenet
Apr 19th 2007, 12:23 am
I revise input_data.php to this:


<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

include ("server.php");

$nim = $_POST['nim'];
$nama = $_POST['nama'];
$jk = $_POST['jk'];
$jurusan = $_POST['jurusan'];
$foto = $_POST['foto'];

// kata yang di ucwords() akan mempunyai huruf pertamanya
// huruf kapital
// walaupun sengaja di tulis dalam huruf kecil

$nama = ucwords($nama);

$koneksi = mysql_connect ($host, $user, $pass)
or die (mysql_error());
mysql_select_db($db) or die (mysql_error());

// Copy file ke dalam folder ../image

copy ($foto, "../image/$foto");

// Karena hanya memasukkan informasi mahasiswa maka
// untuk pengisian nilai dan grade di buatkan form tersendiri
// sehingga pada file ini dikosongi

mysql_query ("INSERT into mhs ('nim',
'nama',
'jk',
'angkatan',
'jurusan',
'foto')
VALUES ('$nim', '$nama', '$jk', '', '$jurusan', '$foto')", $koneksi)
or die (mysql_error());

include ("menu.php");

?>


Now, I receive the following error:

Notice: Undefined index: foto in /home/davenet/public_html/php/input_data.php on line 11
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''nim', 'nama', 'jk', 'angkatan', 'jurusan', 'foto') VALUES ('0100910054', ' at line 1

Line 11 is $foto = $_POST['foto'];

more ideas?

sea otter
Apr 19th 2007, 2:12 am
$_POST['foto'] doesn't exist, which means it wasn't passed in with the form post. You need to check for this.


if (isset($_POST['foto']))
{
$foto = $_POST['foto'];
}
else
{
// handle error here, or set $foto to some default
}

You need to do this for each of the POST variables.

davenet
Apr 20th 2007, 8:33 pm
Another revision of input_data.php:


<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

include ("server.php");

//$nim = $_POST['nim'];
//$nama = $_POST['nama'];
//$jk = $_POST['jk'];
//$jurusan = $_POST['jurusan'];

if (isset($_POST['nim']))
{
$nim = $_POST['nim'];}
else{
// handle error here, or set $foto to some default
$nim = '';}

if (isset($_POST['nama']))
{
$nama = $_POST['nama'];}
else{
// handle error here, or set $foto to some default
$nama = '';}

if (isset($_POST['jk']))
{
$jk = $_POST['jk'];}
else{
// handle error here, or set $foto to some default
$jk = '0';}

if (isset($_POST['nilai']))
{
$nilai = $_POST['nilai'];}
else{
// handle error here, or set $foto to some default
$nilai = '0';}

if (isset($_POST['grade']))
{
$grade = $_POST['grade'];}
else{
// handle error here, or set $foto to some default
$grade = '';}

if (isset($_POST['jurusan']))
{
$jurusan = $_POST['jurusan'];}
else{
// handle error here, or set $foto to some default
$jurusan = '';}

if (isset($_POST['foto']))
{
$foto = $_POST['foto'];}
else{
// handle error here, or set $foto to some default
$foto = NULL;}

// kata yang di ucwords() akan mempunyai huruf pertamanya
// huruf kapital
// walaupun sengaja di tulis dalam huruf kecil

$nama = ucwords($nama);

$koneksi = mysql_connect ($host, $user, $pass)
or die (mysql_error());
mysql_select_db($db) or die (mysql_error());

// Copy file ke dalam folder ../image

copy ($foto, "../image/$foto");

// Karena hanya memasukkan informasi mahasiswa maka
// untuk pengisian nilai dan grade di buatkan form tersendiri
// sehingga pada file ini dikosongi

mysql_query ("INSERT into mhs ('nim',
'nama',
'jk',
'angkatan',
'jurusan',
'foto')
VALUES ('$nim', '$nama', '$jk', '', '$jurusan', '$foto')", $koneksi)
or die (mysql_error());

include ("menu.php");

?>


and


You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''nim', 'nama', 'jk', 'angkatan', 'jurusan', 'foto') VALUES ('0100910054', ' at line 1


I still have no clue how to fix the SQL syntax. From the error message it seems like they recognize the VALUES. I tried to change the SQL syntax several times by trying delete the ' mark or the variables, and the result is still remains.

any more suggestion?

nico_swd
Apr 20th 2007, 8:40 pm
Remove the single quotes around the field names.

davenet
Apr 20th 2007, 9:32 pm
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Syafii, on, , kosong, )' at line 7


now, this massage appear and the data is not yet recorded.

sea otter
Apr 20th 2007, 10:59 pm
change $foto=NULL; to $foto='NULL'.

davenet
Apr 21st 2007, 5:49 am
New revision of input_data.php



<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

include ("server.php");

//$nim = $_POST['nim'];
//$nama = $_POST['nama'];
//$jk = $_POST['jk'];
//$jurusan = $_POST['jurusan'];

if (isset($_POST['nim']))
{
$nim = $_POST['nim'];}
else{
// handle error here, or set $foto to some default
$nim = '';}

if (isset($_POST['nama']))
{
$nama = $_POST['nama'];}
else{
// handle error here, or set $foto to some default
$nama = '';}

if (isset($_POST['jk']))
{
$jk = $_POST['jk'];}
else{
// handle error here, or set $foto to some default
$jk = '0';}

if (isset($_POST['nilai']))
{
$nilai = $_POST['nilai'];}
else{
// handle error here, or set $foto to some default
$nilai = '0';}

if (isset($_POST['grade']))
{
$grade = $_POST['grade'];}
else{
// handle error here, or set $foto to some default
$grade = '';}

if (isset($_POST['jurusan']))
{
$jurusan = $_POST['jurusan'];}
else{
// handle error here, or set $foto to some default
$jurusan = '';}

if (isset($_POST['foto']))
{
$foto = $_POST['foto'];}
else{
// handle error here, or set $foto to some default
$foto = 'NULL';}

// kata yang di ucwords() akan mempunyai huruf pertamanya
// huruf kapital
// walaupun sengaja di tulis dalam huruf kecil

$nama = ucwords($nama);

$koneksi = mysql_connect ($host, $user, $pass)
or die (mysql_error());
mysql_select_db($db) or die (mysql_error());

// Copy file ke dalam folder ../image

copy ($foto, "../image/$foto");

// Karena hanya memasukkan informasi mahasiswa maka
// untuk pengisian nilai dan grade di buatkan form tersendiri
// sehingga pada file ini dikosongi

mysql_query ("INSERT into mhs (nim,
nama,
jk,
angkatan,
jurusan,
foto)
VALUES ($nim, $nama, $jk, , $jurusan, $foto)", $koneksi)
or die (mysql_error());

include ("menu.php");

?>




and new error message:


Warning: copy(NULL) [function.copy]: failed to open stream: No such file or directory in /home/davenet/public_html/php/input_data.php on line 73
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Syafii, on, , kosong, NULL)' at line 7


Line 73 is copy ($foto, "../image/$foto");

What should I change that code to?

sea otter
Apr 21st 2007, 1:41 pm
You shouldn't change that line of code. The problem goes back to the same one which has been the cause of everything else: missing or incorrect input paramters to the page.

You're halfway towards validating the input correctly with all the "if" statements at the top of the file, but setting all the defaults to '' is the problem. Most of those parameters seem to need more logical defaults.

Instead of simply setting all your variables to '' you need to display an error message to the user and redisplay the form. You should not continue doing things if any of those variables contain invalid values, and from the looks of your code and MySQL database schema, emtpy/null strings are invalid values.

This is how I often handle these things:


// default to no error message
$message = '';

if (!$_POST['foto'])
$message .= 'Required parameter foto is missing.<br />';
else
$foto = $_POST['foto'];

if (!$_POST['nim'])
$message .= 'Required parameter nim is missing.<br />';
else
$nim = $_POST['nim'];

//etc. for each parameter

if ($message) // we have an error, so display it and redisplay the form
{
echo $message;
// do whatever
}
else // no errors, so process the data
{
copy(....);
call_mysql_whatever(....);
}



You'll need to modify that to fit into your page correctly, especially the big "if" block.

Notice that for each missing parameter, the message string grows longer because of the .= assignment.

davenet
Apr 22nd 2007, 6:14 am
Here is my database schema:
------------------------------------------------------------

CREATE TABLE 'jurusan' (
'kode_jurusan' char(3) NOT NULL default '',
'nama_jurusan' char(25) NOT NULL default '',
PRIMARY KEY ('kode_jurusan')
) TYPE=MyISAM;

CREATE TABLE 'mhs' (
'nim' char(10) NOT NULL default '',
'nama' char(25) NOT NULL default '',
'jk' enum ('1', '0') NOT NULL default '0',
'nilai' int(3) NOT NULL default '0',
'grade' char(1) NOT NULL default '',
'jurusan' char(3) NOT NULL default '',
'foto' char(15) default NULL,
PRIMARY KEY ('nim')
) TYPE=MyISAM;

-------------------------------------------------------

And I have this for my new revision:


<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');

include ("server.php");
include ("menu.php");

// kata yang di ucwords() akan mempunyai huruf pertamanya
// huruf kapital
// walaupun sengaja di tulis dalam huruf kecil
$nama = ucwords($nama);

$koneksi = mysql_connect ($host, $user, $pass) or die (mysql_error());
mysql_select_db($db) or die (mysql_error());



// default to no error message
$message = '';
if (!$_POST['nim'])
$message .= 'Required parameter nim is missing.<br />';
else $nim = $_POST['nim'];
if (!$_POST['nama'])
$message .= 'Required parameter nama is missing.<br />';
else $nama = $_POST['nama'];
if (!$_POST['jk'])
$message .= 'Required parameter jk is missing.<br />';
else $jk = $_POST['jk'];
if (!$_POST['jurusan'])
$message .= 'Required parameter jurusan is missing.<br />';
else $jurusan = $_POST['jurusan'];
if (!$_POST['foto'])
$message .= 'Required parameter foto is missing.<br />';
else $foto = $_POST['foto'];
//etc. for each parameter
if ($message) // we have an error, so display it
{ echo $message; // do whatever

// and redisplay the form



}else // no errors, so process the data
{
// Copy file ke dalam folder ../image
copy ($foto, "../image/$foto");

// Karena hanya memasukkan informasi mahasiswa maka
// untuk pengisian nilai dan grade di buatkan form tersendiri
// sehingga pada file ini dikosongi
mysql_query ("INSERT into mhs (nim,
nama,
jk,
angkatan,
jurusan,
foto)
VALUES ($nim, $nama, $jk, , $jurusan, $foto)", $koneksi)
or die (mysql_error());
}

?>


and I have this for output:


[ Input Data Mahasiswa ] [ Input Nilai Mahasiswa ] [ Daftar Mahasiswa ] [ Data Jurusan ] [ Input Data Jurusan ]
Notice: Undefined variable: nama in /home/davenet/public_html/php/input_data.php on line 11

Notice: Undefined index: foto in /home/davenet/public_html/php/input_data.php on line 32
Required parameter foto is missing.


I receive some error message. I wonder is there any way to redisplay the form just by quoting the form file name (input_data_mhs.php) or do I have to copy and paste the whole code to (input_data.php)?


It appears that the error message in:

Notice: Undefined variable: nama in /home/davenet/public_html/php/input_data.php on line 11

has to do with:
$nama = ucwords($nama);

I thought I already type in nama field correctly which is char(25). but they still display the error or maybe I just should revise "$nama = ucwords($nama);" code?

I have no idea what to do with the error message in foto line 32. since I thought I already type in a file name (char(15)).

Thanks for help.