-1

Im trying to create a form that posts the information from the form into the database. But my coding doesn't work! May someone please help me? Here's the code:

This is the refund.php file with the form:

<?php
include "../autoload.php";
?>

<!DOCTYPE html>
<html>
   <head>
      <link rel="stylesheet" type="text/css" class="ui" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.8/semantic.css">
      <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.8/semantic.js"></script>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
      <link rel="stylesheet" href="../assets/css/main5.css" media="screen">
      <meta charset="utf-8">
      <title>Refund site</title>
   </head>
   <body>
      <div class="admin-panel">
         <div class="content">
            <h1>Refund</h1>
            <br>
            <a href="index.php">Back</a>
            <br>
            <form class="refund" action="insert.php" method="post">
               <i class="fa fa-user" aria-hidden="true"></i><input type="text" name="username" value="" placeholder="Username"><br><br>
               <i class="fa fa-list" aria-hidden="true"></i><input type="email" name="email" value="" placeholder="email"><br><br>
               <i class="fa fa-list" aria-hidden="true"></i><input type="text" name="kontonummer" value="" placeholder="phone"><br><br>
               <button type="submit" name="post_news">Send</button>
            </form>
         </div>
      </div>
   </body>
</html>

And this is the insert.php file where the execution happens:

<?php
include "../autoload.php";

if (isset($_POST['refund'])) {

    $username    = $_POST['username'];
    $email       = $_POST['email'];
    $phone = $_POST['phone'];

    $refund = new refund();
    $refund->post_news($username, $email, $phone);

}

?>

Can someone please help me with what's wrong? Need help Quick!

Regards, Henry

SamHecquet
  • 1,818
  • 4
  • 19
  • 26
Test Hard
  • 1
  • 3
  • `$refund->post_news($username, $email, $phone);` what is this? How are we supposed to know what does not work if we can't see the respective code? If it's the code in `post_news` that does not work, we can't guess what's wrong. – Paul Kertscher Oct 15 '17 at 17:05

2 Answers2

1

Your question not clearly enough to found the problem, here's the quick answer

Where did you set your $_POST['refund'] in HTML?

if (isset($_POST['refund'])) {

you may add

<input type="hidden" name="refund" value="anything">

and also the $_POST['phone'] seems not set correctly

<input type="text" name="kontonummer" value="" placeholder="phone">

did not match

$phone = $_POST['phone'];

Stanley Cheung
  • 929
  • 7
  • 22
0

actually your mistake is here $_POST['refund'] which is actually not found in your form...change the following code as belowif (isset($_POST['post_news'])) {