How to call two different webpages when the user clicks submit button?

My code looks likes this:

<form action="register.php" method="post">
  <input type="text" name="uname">
  <input type="submit" >
</form>

In register.php file I have a database connection codes. I need to load another html page after submitting the form simultaneously if the database is connected through the register.php file.

How to do that?

Simply redirect the user to the second page once the registration is successful, through means of the header() function:

index.php:

<form action="register.php" method="post">
  <input type="text" name="uname">
  <input type="submit" >
</form>

register.php:

// Process registration
if (valid) {
  header('success.php);
}

success.php:

// Thank the user for registering

Alternatively, you could always simply process your success page on register.php itself.

Hope this helps! :)

Redirect the registration page to the html page in register.php file after the code for inserting the registration details as after the details will be saved , next line of code that is : header('Location: mypage.html')will execute which will take the user to the html page mentioned in the header location.

Welcome to SO. It sounds to me like you don't actually need to load 2 URLs simultaneously and what you are looking for is an if statement to execute some code only if post data is set

if(!empty($_POST)){
  //code to execute when form is submitted
}
else {
  //code to execute otherwise
}

If you do need to make a request to 2 URLs at the same time you are looking for an AJAX request.

More detail in your question about your setup and end goal would be useful to help further.

in your Register.Php add something like this check your Sql result something like this

$sql='select * Tablename where condition'

$result= fetch($sql)
$row=fetch_array($result)asdsad
if($row>0){
header(Location:'connected.php') // whatever your html
}
else {header(Location:"failed.php")//whenever query got no row
}

0 Comment

NO COMMENTS

LEAVE A REPLY

Captcha image