Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6589707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:12:34+00:00 2026-05-25T17:12:34+00:00

So I have a form that looks so. <form action=thanks.php method=post class=niceform name=myform> <table>

  • 0

So I have a form that looks so.

<form action="thanks.php" method="post" class="niceform" name="myform">
<table>
<tr>
<td><label for="company_name">Company Name</label></td>
<td><input type="text" name="company" value="" size="38" /></td>
</tr>
// and so on

I have the validation by javascript. But the problem is that when I go directly to thanks.php from localhost/mysite/form/thanks.php I have an empty row that is inserted when I look at phpmyadmin. Thanks.php looks like so.

<?php
// open the connection
$conn = mysql_connect("localhost", "root", "password");
// pick the database to use
mysql_select_db("company_register",$conn);

$sql = "INSERT INTO `tblsignups` VALUES ('NULL', '$_POST[company]', '$_POST[email]', '$_POST[phone]', '$_POST[address]', '$_POST[comments]', '$_POST[contact_person]')";

$result = mysql_query($sql, $conn) or die(mysql_error());

mysql_close($conn);
?>
// And I have a thank you msg I display

How do I check that if some one should directly go to thanks.php I tell them to go fill the form first and do not put anything on the database

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:12:34+00:00Added an answer on May 25, 2026 at 5:12 pm

    here is a sketch example

    after receiving POST data you have to check it and raise error flag
    in case of some errors show the form back instead of saving it

    <?  
    if ($_SERVER['REQUEST_METHOD']=='POST') {  
    
      $err = array();
      //performing all validations and raising corresponding errors
      if (empty($_POST['name']) $err[] = "Username field is required";  
      if (empty($_POST['text']) $err[] = "Comments field is required";  
    
      if (!$err) {  
        // if no errors - saving data 
        // and then redirect:
        header("Location: ".$_SERVER['PHP_SELF']);
        exit;
      }  else {
        // all field values should be escaped according to HTML standard
        foreach ($_POST as $key => $val) {
          $form[$key] = htmlspecialchars($val);
        }
    } else {
      $form['name'] = $form['comments'] = '';  
    }
    include 'form.tpl.php';
    ?>  
    

    and modify your form to make it possible to show errors

    <? if ($err): ?>
      <? foreach($err as $e): ?>
    <div class="err"><?=$e?></div>
      <? endforeach ?>
    <? endif ?>
    <form>
      <input type="text" name="name" value="<?=$form['name']?>">
      <textarea name="comments"><?=$form['comments']?></textarea>
      <input type="submit">
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that looks like the following: <form id=MyForm name=MyForm method=post action=index.php> <input
I have a form for editing notifications that looks like: <form action='edit.php' method =
I have an Action method in an ASP.NET MVC Controller class that handles form
I have a form that looks kind of like this: <div> <div class=contact> <h1>Person's
I have a form that looks like this: class SampleForm(forms.Form): text = forms.CharField(max_length=100) In
I have a simple form that looks like so <% remote_form_for post, :url =>
I have a win form UI that looks like a typical calculator. Naturally I
I have a pretty simple ASP.NET Web Form that looks a bit like the
I have a form that collects a data using ASP.NET MVC. It looks like
Let's say that I have a file (file1.php) with a simple form with the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.