1 Replies - 5890 Views - Last Post: 06 December 2010 - 08:08 AM

#1 TehRoot  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 51
  • Joined: 13-December 09

Link a page with a click of a submit button

Posted 06 December 2010 - 05:46 AM

Hey guys, I'm trying to figure out how to link a submit button to check against a third party API when someone clicks a submit button with a piece of PHP, and after goes and redirects to a thank you webpage.

This is my basic login code so far.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
<-->
.banner {
      background-color:#707070;
      width: 50%;
	  
      height: 40px;
      font-size: 15px;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body bgcolor="#666666">
<div align="top"><img src="Plain-Banner-605x136.gif" width="784" height="150" /></div>


<table  width="784" height="272" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#CCCCCC">

  <tr>
<th><div align="center"><u>Registration Page</u><br />
</div> 
Enter your EVE Username and API Key
</th>
    <td align="middle" width="300" height="270"><form id="form1" name="form1" method="post" action="">
    <div aling="top">
<center><h3>Register Now</h3></center>
<form>
EVE Username: 
<input type="text" name="Firstname">
<br />
EVE API Key:   
<input type="text" name"lastname"><br />
<a href='test.html'><input type ="submit" value ="Submit"></a>
</form>    </td>
  </tr>
</table>
<table width="782" height="30" border="1" align="left" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#CCCCCC">
  <tr>
    <td width="223" height="21"><center> Register on the Site today :D/></center></td>
  </tr>
</table>

</html>


I have the php code already, I just don't know how to link it through the submit button, and then display a thank you page if the request was successful for communication, which then loads a list, but I'm more focused on how to just get the button to link to another page embedded with a php script.

Is This A Good Question/Topic? 0
  • +

Replies To: Link a page with a click of a submit button

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3718
  • View blog
  • Posts: 5,989
  • Joined: 08-June 10

Re: Link a page with a click of a submit button

Posted 06 December 2010 - 08:08 AM

Hey.

You can just point the form to your API script, and then have that redirect you to the thank you page.

<form action="api_check.php" method="post">
    <input type="text" name="username"><br>
    <input type="text" name="api_key"><br>
    <input type="submit">
</form>


<?php
# Page: api_check.php

if(isset($_POST['username'], $_POST['api_key'])) {
    # Do your API checking here.

    if($success) {
        # Redirect to a thank you page if successful.
        header('Location: thank_you_page.html');
    }
    else {
        # Redirect to a error page if unsuccessful.
        header('Location: error_page.html');
    }
}
else {
    # The data is missing, so just send them back
    # to the form. (I also put an error in the GET
    # string which could be used to print an error 
    # message with the form.)
    header('Location: form_page.php?error=form_nodata');
}
?>



P.S.
You really shouldn't use tables to set up the layout of your pages. That method has been obsolete for years. Instead the elements should be positioned using divs and CSS rules.
Also, your page is missing the Doctype.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1