faces3 Posted April 24, 2013 Share Posted April 24, 2013 (edited) 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 April 24, 2013 by faces3 Quote Link to comment https://forums.phpfreaks.com/topic/277264-problem/ Share on other sites More sharing options...
computermax2328 Posted April 24, 2013 Share Posted April 24, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/277264-problem/#findComment-1426384 Share on other sites More sharing options...
Jessica Posted April 24, 2013 Share Posted April 24, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/277264-problem/#findComment-1426392 Share on other sites More sharing options...
computermax2328 Posted April 24, 2013 Share Posted April 24, 2013 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/277264-problem/#findComment-1426396 Share on other sites More sharing options...
Jessica Posted April 24, 2013 Share Posted April 24, 2013 Yeah that would be it. Quote Link to comment https://forums.phpfreaks.com/topic/277264-problem/#findComment-1426397 Share on other sites More sharing options...
faces3 Posted April 24, 2013 Author Share Posted April 24, 2013 What must do then? Quote Link to comment https://forums.phpfreaks.com/topic/277264-problem/#findComment-1426449 Share on other sites More sharing options...
Solution Jessica Posted April 24, 2013 Solution Share Posted April 24, 2013 Put your query in a string and execute it. mysqli_query Quote Link to comment https://forums.phpfreaks.com/topic/277264-problem/#findComment-1426450 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.