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

  • SEARCH
  • Home
  • 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 6895495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:54:56+00:00 2026-05-27T06:54:56+00:00

This is a very simple question, and most likely requires a very simple answer.

  • 0

This is a very simple question, and most likely requires a very simple answer. I am pulling data from a MYSQL database, and constructing a table using the retrieved data. I am constructing a CRUD table, having the last two columns being ‘edit’ and ‘delete’. The form I am constructing the final two columns will look something like this:

The following is found in Welcome.php:

<form action="delete.php" method="POST">
<input type="hidden" value="ptest"/>
<input type="submit" value="Sign Up"/>
</form>

However, should I make the form’s action call the current page instead?

<form action="welcome.php" method="POST">
<input type="hidden" value="ptest"/>
<input type="submit" value="Sign Up"/>
</form>

I’m very new to PHP and I want to ensure that I am following proper protocol. If this is more an opinion than anything else, please at least leave me your professional opinions.

Thank you very much,

Evan

  • 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-27T06:54:57+00:00Added an answer on May 27, 2026 at 6:54 am

    You shouldn’t.
    There is not a strict standard.

    Being a newbie, you may find that separate file for the each action easier to understand. So, go for it.
    With more experience you will find that having all actions in a single file makes the code shorter and more convenient.

    What you have to have in a separate file – is a form itself.
    So, you’ll be able to use the same form for adding new record, editing existing one and to show submit errors.

    Here is an example of one-pager. It does not delete though but can give you a general idea.
    It lets you add, edit and browse records.

    the code

    <?  
    mysql_connect(); 
    mysql_select_db("new"); 
    $table = "test"; 
    if($_SERVER['REQUEST_METHOD']=='POST') { //form handler part: 
      $name = mysql_real_escape_string($_POST['name']); 
      if ($id = intval($_POST['id'])) { 
        $query="UPDATE $table SET name='$name' WHERE id=$id"; 
      } else { 
        $query="INSERT INTO $table SET name='$name'"; 
      } 
      mysql_query($query) or trigger_error(mysql_error()." in ".$query); 
      header("Location: http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);  
      exit;  
    }  
    if (!isset($_GET['id'])) { //listing part: 
      $LIST=array(); 
      $query="SELECT * FROM $table";  
      $res=mysql_query($query); 
      while($row=mysql_fetch_assoc($res)) $LIST[]=$row; 
      include 'list.php'; 
    } else { // form displaying part: 
      if ($id=intval($_GET['id'])) { 
        $query="SELECT * FROM $table WHERE id=$id";  
        $res=mysql_query($query); 
        $row=mysql_fetch_assoc($res); 
        foreach ($row as $k => $v) $row[$k]=htmlspecialchars($v); 
      } else { 
        $row['name']=''; 
        $row['id']=0; 
      } 
      include 'form.php'; 
    }  
    ?>
    

    The templates
    form.php

    <? include TPL_TOP ?>
    <form method="POST">
    <input type="text" name="name" value="<?=$row['name']?>"><br>
    <input type="hidden" name="id" value="<?=$row['id']?>">
    <input type="submit"><br>
    <a href="?">Return to the list</a>
    </form>
    <? include TPL_BOTTOM ?>
    

    and list.php

    <? include TPL_TOP ?>
    <a href="?id=0">Add item</a>
    <? foreach ($LIST as $row): ?>
    <li><a href="?id=<?=$row['id']?>"><?=$row['name']?></a>
    <? endforeach ?>
    <? include TPL_BOTTOM ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very simple question with a simple answer, but it is not
This is probably a very silly and simple question to most of you, but
This is a very simple question, but I can't seem to find something about
This is a very simple question and I feel stupid for asking it, but
This may be very simple question,But please help me. i wanted to know what
This should be very simple question. There are many programming languages out there, compiled
I'm sure this is a very simple question, but embarrassed to say I can't
Alright, this is a very simple question. I just installed Tomcat 6 on my
This must be a very simple question, but I don't seem to be able
this may be a very simple question, but is it possible to force a

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.