Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

i'm new to php.

i have designed only one php page for whole website using sections.

And in each section i have button,

now how can i use form action for each button to call
specific php page, on button click.

Php Insertion Code:
<form action="InsertInterview.php" method="post">



insertinterview.php code:

<?php

include Conn.php;
if(!$conn)
{
	die('Could not connect to the server!');
}
else{
	$sql = 'INSERT INTO Interview'.
			'( 
			Employer_EmailID, 
			Job_Position, 
			Message, 
			InterviewDate, 
			InterviewTime, 
			Location, 
			InsertionDate)'.
			' VALUES ('.
				$_POST['iemail'].','.
				$_POST['iposition'].','.
				$_POST['imessage'].','.
				$_POST['idate'].','.
				$_POST['itime'].','.
				$_POST['ilocaiton'].','.
				$_POST['iemail'].','.
			')';	
			
	$retval = mysql_query($sql, $conn);
	$msg;
	if(!$retval)
	{
		die('Count enter data. ' . mysql_error);	
		$msg = mysql_error;		
	}
	else{
		$msg = 'Data Entered Successfully!';
	}
	
	echo $msg;
	
	mysql_close($conn);
}

?>


I have created InsertInterview.php to insert into mysql and calling this page in form action, but i have one more button for contact me, then for contact me page, how to call its particular page in form action.


SQL
Currently i'm not able to insert records into the mysql database.



can any one please help me.


Thanks
Posted
Updated 3-Feb-16 2:04am
v4
Comments
Afzaal Ahmad Zeeshan 3-Feb-16 7:43am    
What have you designed, and what do you want to do?

The question is very much unclear.
abdul subhan mohammed 3-Feb-16 7:59am    
i have designed only one php page, so i have only one form action.
but i have sections and in each section i have button, so when i click on particular button, particular php page should get called in form action attribute.

But i have only one php page, so one form action attribute. But number of buttons i have.

how to call particular page on particular button click.
Richard Deeming 3-Feb-16 11:16am    
Sounds like you need to use multiple <form> elements in your page - one for each section, wrapping just the fields you want to submit for that section - rather than having a single form wrapping the entire page.
abdul subhan mohammed 4-Feb-16 1:01am    
is my insert php is correct?
because the records are not getting inserted.
Richard Deeming 4-Feb-16 7:13am    
From your description, you've wrapped the entire page in a single <form> element, which is posting to the wrong page. Your insert.php page is never being called.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900