Jump to content

Problem...


faces3
Go to solution Solved by Jessica,

Recommended Posts

Problem with get data form and add database. Its all in same page.

	 <form action= "" method="post">
     <input type="text" name = "database" size="30" />
 <input type="text" name = "firma" size="30" />
 <input type="text" name = "telefon" size="30" />
 <input type="text" name = "email" size="30" />
 <input type="text" name = "koduleht" size="30" />
 <input type="text" name = "kontakt" size="30" />
 <input type="text" name = "aeg" size="30" />
     <input type="submit" value="Add" />
     </form>
<?php
$tabel = $_REQUEST['database'];
$firma = $_REQUEST['firma'];
$tel = $_REQUEST['telefon'];
$email = $_REQUEST['email'];
$kontakt = $_REQUEST['kontakt'];
$con=mysqli_connect("localhost","root","kala", $tabel);
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

INSERT INTO $tabel
            (firma, telefon, email, kontakt)
            VALUES    ('$firma' , '$tel' , '$email' , '$kontakt');


mysqli_close($con);
?>

Edited by faces3
Link to comment
Share on other sites

You are using single page submission, which is fine, but right now you are telling your for to do nothing.

<form action= "" method="post">

Tell it to execute this page.

 

You can also look at this if you want, but I don't see the point of using it. Maybe someone else could explain.
http://www.html-form-guide.com/php-form/php-form-action-self.html

Link to comment
Share on other sites

You are using single page submission, which is fine, but right now you are telling your for to do nothing.

<form action= "" method="post">
Tell it to execute this page.

 

You can also look at this if you want, but I don't see the point of using it. Maybe someone else could explain.

http://www.html-form-guide.com/php-form/php-form-action-self.html

That is fine, it will submit to the page it's already on.

 

The problem is the OP didn't actually state a problem.

Link to comment
Share on other sites

He doesn't run a mysqli query??

<?php
$tabel = $_REQUEST['database'];
$firma = $_REQUEST['firma'];
$tel = $_REQUEST['telefon'];
$email = $_REQUEST['email'];
$kontakt = $_REQUEST['kontakt'];
$con=mysqli_connect("localhost","root","kala", $tabel);
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

INSERT INTO $tabel
            (firma, telefon, email, kontakt)
            VALUES    ('$firma' , '$tel' , '$email' , '$kontakt');


mysqli_close($con);
?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.