hi
i want ot ask if i can run a php script in the same page where i put it
i mean i do a forum with a code in the action tag which allow the page to run in the same page or is it posible to run only the form without loading all the page
i hope what i have said was clear because i dont have a very good english

I don't fully understand what you're asking. But PHP is a server-side language - Meaning that any request by the client must be sent to the server so PHP can process it.

You can process form data on the same page by using the $_SERVER global, as long as it is saved as .php:

<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">

Otherwise, you can send it to another page to be processed:

<form action="process.php" method="post">

thank you
this is what i was asking about

hi
i want ot ask if i can run a php script in the same page where i put it
i mean i do a forum with a code in the action tag which allow the page to run in the same page or is it posible to run only the form without loading all the page
i hope what i have said was clear because i dont have a very good english

Hello Awah.
I think i know what you are looking for, i picked up this script many months ago and its still very useful.
I recommend you put this code inside a <td> tag for fast content load without the whole page refreshing.

<?php

	$page = $_GET['page'];
	if ($page)
	{
		$path = "inc/".$page.".php";
		
		if(file_exists($path))
		{
			include($path);	
		}
		else
		{
			echo "Error: That page does not exist! ";
		}
		
	}
	else 
	{
		include('any-page-here.php');
}?>

1.Change the 'page' inside $_GET; to what you want the header to look like.
Example; index.php?page=

2. Change the $path = "inc/".$page.".php"; to the location of the php files you want to run, can be left with "/" if its in the same directory as index. Mine is "inc/" in this code.

3. Make sure that the links you want this code to run is like this: index.php?page=YOURLINK
the 'page' should be changed if you change tip #1. above.

NOTE! You can use this code as many times you want in your php file as long as you change tip #1. to a unique character, word or number.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.