how to use two buttons with php


Posted on 16th Feb 2014 07:03 pm by admin

hi i have one form. there are three fields which are to be filled by the user. and then there are two buttons. ob clicking first button i want to save user's provided data to the database display the same page again. and on clicking second button the provided data will be saved and will be taken to next page.

my problem is with these buttons how can i set up these buttons to do the the action?

my code is here
Code: [Select]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>

<body>
<form name="form1" method="post" action="">
<label>Degree Name:
<input type="text" name="textfield" id="textfield">
</label>
<p>
<label>CGPA:
<input type="text" name="textfield2" id="textfield2">
</label>
</p>
<p>
<label>Institute:
<input type="text" name="textfield3" id="textfield3">
</label>
</p>
<p>
<label>
<input type="submit" name="button" id="button" value="Save And Add Another">
</label>
</p>
<p>
<label>
<input type="submit" name="button2" id="button2" value="Save And Proceed to Next Step">
</label>
</p>
</form>
<?php
$db = mysql_connect("localhost");
mysql_select_db("job", $db);
$addcv = mysql_query("insert into cv
(
degree,
cgpa,
institute
)
values
(
'".$degree."',
'".$cgpa."',
'".$institute."',
)");
echo "Your data is added.";
?>
</body>
</html>

No comments posted yet

Your Answer:

Login to answer
144 Like 24 Dislike
Previous forums Next forums
Other forums

split values
I have values that are returned to me in this format:

name=>test,age=>49

MASS PM
Hello all, I'm trying to send mass private messages to users in my database but keep getting an erro

simplexml_load_file and rss problem
Hi,

I have a problem parsing an rss feed using simplexml_load_file - this is strange as i hav

how to export excel file in same server
My first post - php newbie, so appreciate your support.

I'm currently using headers to save w

Rounding a number queried from a database
I know that to display a rounded number you just do echo "round($number)";. But how would

simple php table loop
Hi all,

I've the following code

<?php // Create category options

form help
this doesn't work. i want the form action to go the location.href of the submit button chosen.. how

Escape Latin Characters
I need to escape latin characters in an xml doc. Example: "é" is escaped to "é". I thoug

Mail from PHP form not always ending up in my inbox?
Hi guys,

I'm a real newbie to PHP and have managed to put together a simple mail form that se

PHP using IF to display error
i have a MySQL query and i want to display 1 thing only if the number of affected rows is >=1

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash