plodos Posted August 7, 2008 Share Posted August 7, 2008 I havent any exprience....could you check the code... I used two insert, 3 different table and join Its is working but, thats better to make a good code;) <?php include("dbconfig.php"); $title=$_POST['title']; $name = $_POST['name']; $surname = $_POST['surname']; $email = $_POST['email']; $country = $_POST['country']; $university = $_POST['university']; $university_dept = $_POST['university_dept']; $phone=$_POST['phone']; $fax = $_POST['fax']; $committee = $_POST['committee']; $link = $_POST['link']; $research = $_POST['research']; $address = $_POST['address']; $date = date("Y-m-d H:m:s"); $total_id = mysql_query("SELECT * FROM PERSON"); $num_rows = mysql_num_rows($total_id); $num_rows++; $sql = "select committee_id from committee where name='$committee'"; $id = mysql_query($sql); $result = mysql_fetch_assoc($id); foreach ($result as $v) { $k=$v; } $count_commit = $k; // which committe selected $add_person= mysql_query(" INSERT INTO person (title,fname,lname,email,country,university,university_dept,phone,fax,research_field,address,paper_link,date) VALUES ('$title','$name','$surname','$email','$country','$university','$university_dept','$phone','$fax','$research','$address','$link','$date') "); $add_join_person_committee = mysql_query(" INSERT INTO join_person_committee (person_id,committee_id) values ('$num_rows','$count_commit') "); if($add_person && $add_join_person_committee) { header('Location: http://localhost/committee/organization'); } else { echo "Error"; } ?> dbase.sql CREATE TABLE `person` ( `person_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `title` VARCHAR(20) NOT NULL, `fname` VARCHAR( 40 ) NOT NULL , `lname` VARCHAR( 40 ) NOT NULL , `email` VARCHAR( 128 ) NOT NULL , `country` VARCHAR( 128 ) NOT NULL , `university` TEXT NOT NULL, `university_dept` TEXT NOT NULL, `phone` VARCHAR(40) NOT NULL, `fax` VARCHAR(40) NOT NULL, `research_field` TEXT NOT NULL, `address` TEXT NOT NULL, `paper_link` TEXT NOT NULL, `date` DATETIME ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE `committee` ( `committee_id` SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` TEXT NOT NULL ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE `join_person_committee` ( `person_id` INT NOT NULL , `committee_id` SMALLINT NOT NULL , PRIMARY KEY ( `person_id` , `committee_id` ) ) ENGINE = MYISAM ; Quote Link to comment https://forums.phpfreaks.com/topic/118694-urgent-comments-pls/ Share on other sites More sharing options...
DarkWater Posted August 7, 2008 Share Posted August 7, 2008 What's the question...? ??? Quote Link to comment https://forums.phpfreaks.com/topic/118694-urgent-comments-pls/#findComment-611120 Share on other sites More sharing options...
discomatt Posted August 7, 2008 Share Posted August 7, 2008 I think he urgently want's us to optimize his code? Freelance section. And for future reference, I refuse to help people who mark their issues as 'Urgent.' What makes your issue more important than everyone else's? This is a forum of volunteers, and we'll help you at our own pace. Quote Link to comment https://forums.phpfreaks.com/topic/118694-urgent-comments-pls/#findComment-611122 Share on other sites More sharing options...
ohdang888 Posted August 7, 2008 Share Posted August 7, 2008 use mysql_real_escape_string($string) to prevent injenctions... example: $title= mysql_real_escape_string($_POST['title']); Quote Link to comment https://forums.phpfreaks.com/topic/118694-urgent-comments-pls/#findComment-611130 Share on other sites More sharing options...
plodos Posted August 7, 2008 Author Share Posted August 7, 2008 I think he urgently want's us to optimize his code? Freelance section. And for future reference, I refuse to help people who mark their issues as 'Urgent.' What makes your issue more important than everyone else's? This is a forum of volunteers, and we'll help you at our own pace. sorry Quote Link to comment https://forums.phpfreaks.com/topic/118694-urgent-comments-pls/#findComment-611133 Share on other sites More sharing options...
revraz Posted August 8, 2008 Share Posted August 8, 2008 Plus, what is urgent about optimizing. It works right? Quote Link to comment https://forums.phpfreaks.com/topic/118694-urgent-comments-pls/#findComment-611266 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.