ravravrav Posted November 23, 2006 Share Posted November 23, 2006 I have a page called skills.html where i can add skills to my skills table.<form action="addskill.php" method="post">Skill name: <input type="text" name="skillname"><br />Skill description: <input type="textarea" rows="5" cols="20" name="description"><br /><input type="Submit">I want to pass skillname and description to addskill.php so that it can add them to the database... how do I do this?This is what I've got so far for addskill.php:<?php$username="x";$password="x";$database="x";mysql_connect(localhost,$username,$password);mysql_close();@mysql_select_db($database) or die( "Unable to select database");mysql_query($query);$query = "INSERT INTO skills VALUES ('',$skillname, $description)";?>What's the correct way :-\?? Thx Link to comment https://forums.phpfreaks.com/topic/28227-passing-a-variable-from-form-to-db/ Share on other sites More sharing options...
fenway Posted November 23, 2006 Share Posted November 23, 2006 You need to access those keys from the $_POST hash. Link to comment https://forums.phpfreaks.com/topic/28227-passing-a-variable-from-form-to-db/#findComment-129245 Share on other sites More sharing options...
exploo Posted November 23, 2006 Share Posted November 23, 2006 yeap, and you should also use: mysql_real_escape_string to prevent SQL-injectionfor examplemysql_real_escape_string($_POST["skillname"])/Magnus Link to comment https://forums.phpfreaks.com/topic/28227-passing-a-variable-from-form-to-db/#findComment-129281 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.