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

#1 TehRoot   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">
<style type="text/css">
.banner {
      width: 50%;
      height: 40px;
      font-size: 15px;
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<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">

<th><div align="center"><u>Registration Page</u><br />
Enter your EVE Username and API Key
    <td align="middle" width="300" height="270"><form id="form1" name="form1" method="post" action="">
    <div aling="top">
<center><h3>Register Now</h3></center>
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>
<table width="782" height="30" border="1" align="left" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#CCCCCC">
    <td width="223" height="21"><center> Register on the Site today :D/></center></td>


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   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4240
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

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

Posted 06 December 2010 - 08:08 AM


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">

# 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');

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