TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-12-2009, 02:14 AM   #1 (permalink)
The Wanderer
 
deden's Avatar
 
Join Date: Oct 2009
Posts: 5
Thanks: 1
deden is on a distinguished road
Default Submit Button Function

Hello Guys,
I have a form with search, update and submit(insert) function. But when I try to click submit button, it cannot run with submit function but looping to search and update function.
Someone help me please?

Here the script:

<?php require_once('Connections/koneksi.php'); ?>
<html>
<head><title>Pencarian Data PNS</title>
</head>
<body bgcolor=#ffffff>
<?php
// Grab POST data sent from form
$field = @$_POST['field'] ;
$find = @$_POST['find'] ;
$searching = @$_POST['searching'] ;

echo "<h2>Hasil Pencarian:</h2><p>";

//If they did not enter a search term we give them an error
if ($find == "")
{
echo "<p>Kamu tidak memasukan field yang dicari!!!";
echo "<br>";
echo '<a href="cari.php">Kembali</a>';
exit;
}

// Otherwise we connect to our Database
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("layanan") or die(mysql_error());

// We perform a bit of filtering
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);

//Now we search for our search term, in the field the user specified
$data = mysql_query("SELECT * FROM datapns WHERE upper($field) LIKE'%$find%'");

//And we remind them what they searched for
echo "<b>Pencarian Anda :</b> " .$find;
//}

//And we display the results
while($result = mysql_fetch_array($data ))
{
$nip = $result['PNS_PNSNIP'];
$nipbaru = $result['PNS_NIPBARU'];
$nama = $result['PNS_PNSNAM'];
$instansi = $result['PNS_INKER'];

echo "<form name='frmUpdate' method='post' action='$_SERVER[PHP_SELF]'>
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td>NIP Lama</td>
<td>:</td>
<td><input type='text' name='nip' value='$nip' size=20 /></td>
</tr>
<tr>
<td>NIP Baru</td>
<td>:</td>
<td><input type='text' name='nip' value='$nipbaru' size=20 /></td>
</tr>
<tr>
<td>Nama</td>
<td>:</td>
<td><input type='text' name='nama' value='$nama' size=40 /></td>
</tr>
<tr>
<td>Instansi</td>
<td>:</td>
<td><input type='text' name='instansi' value='$instansi' size=40 /></td>
</tr>
<tr>
<td>Jenis Pelayanan</td>
<td>:</td>
<td>
<select name='jenis'>
<option value='KARIS/KARSU' >KARIS/KARSU</option>
<option value='STATUS CPNS' >STATUS CPNS</option>
<option value='KARPEG' >KARPEG</option>
<option value='PENSIUN' >PENSIUN</option>
</select>
</td>
</tr>
<tr>
<td>Status Pelayanan</td>
<td>:</td>
<td>
<select name='status'>
<option value='DAFTAR' >DAFTAR</option>
<option value='PROSES' >PROSES</option>
<option value='SELESAI' >SELESAI</option>
</select>
</td>
</tr>
<tr>
<td colspan=3><input type='submit' name='simpan' value='Simpan' /></td>
</tr>
</table>
</form>";

if(isset($_POST['simpan']))
{
$save="insert into frontend set nama='$nama', instansi='$instansi', jenis='jenis', status='$status' where nip= '$nip'";
mysql_query($save) or die("Gagal simpan");
echo "Data atas nama $nama telah berhasil di simpan..";
echo "<meta http-equiv='refresh' content='1;URL=datapns.php'/>";

}
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($data);
if ($anymatches==0)
{
echo "Maaf, data PNS yang Anda cari tidak ada...<br><br>";}
echo '<a href="input.php">Kembali</a>';
echo "<br>";
?>

Thanks,
Deden
deden is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a gallery class Tanax Advanced PHP Programming 25 02-19-2013 04:25 AM
Timezone Class: Dealing with Timezones the Proper Way Wildhoney General 2 01-10-2011 11:01 PM
Next class project? allworknoplay The Lounge 6 04-18-2009 08:33 PM
Part 2: Giving our Currency Conversion Script some Responsibility Wildhoney General 15 03-17-2009 01:53 PM
[Tutorial] How to organize your classes | Part 1 Tanax Advanced PHP Programming 10 03-01-2009 10:08 PM


All times are GMT. The time now is 03:13 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design