![]() |
registration form help
ive created registration form in php,but i could not post the datas in to database,it tells "can not select DB",
im very beginner on this php,so i wanted some very basic steps to create my site..... |
can you post your code?
|
Usually means you havent made the database yet. I dunno about permissions
|
you havent placed this piece of code. mysql_selectdb("databasename"); how would your script know which database to use if you havent specified it :p
|
...or better yet, use mysqli and add it to your construct...
PHP Code:
|
my code is here.....pl help me to do
<?php session_start(); $link = mysql_connect('localhost', '', ''); if (!$link) { die('Could not connect: ' . mysql_error()); } $dbselect = mysql_select_db('vigrav')or die("Can not select "); if(!$dbselect){ die('Could not connect: ' . mysql_error()); } if($_REQUEST["Check"] == 1) { $email = $_POST["email"]; $password = $_POST["password"]; $conpassword = $_POST["conpassword"]; $name1 = $_POST["firstname"]; $name2 = $_POST["lastname"]; $name3 = $_POST["surname"]; $lccode = $_POST["lccode"]; $lcitycode = $_POST["lcitycode"]; $land2 = $_POST["land2"]; $mccode = $_POST["mccode"]; $phone = $_POST["phoneno"]; $country = $_POST["countryofresidence"]; $state = $_POST["state"]; $city = $_POST["city"]; $presaddr1 = $_POST["conaddress"]; $presaddr2 = $_POST["conaddress1"]; $presaddr3 = $_POST["conaddress2"]; $prespin = $_POST["pincode1"]; $permaddr1 = $_POST["peraddress"]; $permaddr2 = $_POST["peraddress1"]; $permaddr3 = $_POST["peraddress2"]; $permpin = $_POST["pincode2"]; $query = "insert into jobseekerstep1(email,password,confirmpassword,firs tname,lastname,surname,landlinecode,landlinecityco de,landlineno,mobilecode,mobileno,country,state,ci ty,present1,present2,present3,presentpin,permanent 1,permanent2,permanent3,permanentpin) values('$email','$password','$conpassword','$name1 ','$name2','$name3','$lccode','$lcitycode','$land2 ','$mccode','$phone','$country','$state','$city',' $presaddr1','$presaddr2','$presaddr3','$prespin',' $permaddr1','$permaddr2','$permaddr3','$permpin')" ; $result = mysql_query($query); $query1 = "select id from jobseekerstep1"; $res = mysql_query($query1); while($row = mysql_fetch_array($res,MYSQL_BOTH)) $jid = $row["id"]; $_SESSION["id"] = $jid; $_SESSION["email"] = $_POST["RegEmail"]; $_SESSION["password"] = $_POST["RegPassword"]; $_SESSION["name1"] = $_POST["Name1"]; $_SESSION["name2"] = $_POST["Name2"]; $_SESSION["name3"] = $_POST["Name3"]; $_SESSION["phone"] = $_POST["Phoneno"]; $_SESSION["country"] = $_POST["Country"]; $_SESSION["state"] = $_POST["State"]; $_SESSION["city"] = $_POST["City"]; $_SESSION["presaddr1"] = $_POST["pres1"]; $_SESSION["presaddr2"] = $_POST["pres2"]; $_SESSION["presaddr3"] = $_POST["pres3"]; $_SESSION["prespin"] = $_POST["prespin"]; $_SESSION["permaddr1"] = $_POST["perm1"]; $_SESSION["permaddr2"] = $_POST["perm2"]; $_SESSION["permaddr3"] = $_POST["perm3"]; $_SESSION["permpin"] = $_POST["permpin"]; } else { $_SESSION["email"]; $_SESSION["password"]; $_SESSION["name1"]; $_SESSION["name2"]; $_SESSION["name3"]; $_SESSION["phone"]; $_SESSION["country"]; $_SESSION["state"]; $_SESSION["city"]; $_SESSION["presaddr1"]; $_SESSION["presaddr2"]; $_SESSION["presaddr3"]; $_SESSION["prespin"]; $_SESSION["permaddr1"]; $_SESSION["permaddr2"]; $_SESSION["permaddr3"]; $_SESSION["permpin"]; $_SESSION["jobid"]; } if($_REQUEST["up"] == "res"){ /*echo '<pre>'; echo print_r($_REQUEST); echo '</pre>';*/ $uploaddir = "C:/wamp/www/vijay/mov_resume/"; $uploadfile = $uploaddir . basename($_FILES['Resume']['name']); if($_FILES['Resume']['name']!="") { if(copy($_FILES['Resume']['tmp_name'], $uploadfile)){ $date = $_POST["date"]; $month = $_POST["month"]; $year = $_POST["year"]; $dob = $_POST["date"]."-".$_POST["month"]."-".$_POST["year"]; $gender = $_POST["gender"]; $qual1 = $_POST["qualification1"]; $coname1 = $_POST["coname1"]; $cotype1 = $_POST["cotype1"]; $spec1 = $_POST["spec1"]; $institute1 = $_POST["institute1"]; $passout1 = $_POST["passout1"]; $qual2 = $_POST["qual2"]; //$coname2 = $_POST["coname2"]; //$cotype2 = $_POST["cotype2"]; //$spec2 = $_POST["spec2"]; //$institute2 = $_POST["institute2"]; //$passout2 = $_POST["passout2"]; //$qual3 = $_POST["qual3"]; //$coname3 = $_POST["coname3"]; //$cotype3 = $_POST["cotype3"]; //$spec3 = $_POST["spec3"]; //$institute3 = $_POST["institute3"]; //$passout3 = $_POST["passout3"]; $expyear = $_POST["expyear"]; $expmonth = $_POST["expmonth"]; $tags = $_POST["tags"]; $jobtitles = $_POST["jobtitles"]; $preferedcountry1 = $_POST["preferedcountry1"]; $preferedstate1 = $_POST["preferedstate1"]; $preferedcity1 = $_POST["preferedcity1"]; $preferedcountry2 = $_POST["preferedcountry2"]; $preferedstate2 = $_POST["preferedstate2"]; $preferedcity2 = $_POST["preferedcity2"]; $preferedcountry3 = $_POST["preferedcountry3"]; $preferedstate3 = $_POST["preferedstate3"]; $preferedcity3 = $_POST["preferedcity3"]; $rupees = $_POST["rupees"]; $dollar = $_POST["dollar"]; $skills = $_POST["skills"]; $Functional = array(); $Functional = $_POST["Functional"]; $len = count($Functional); for($i=0; $i<$len; $i++){ if($Functional[$i]==1){ $Functional[$i] = "IT, Software Services"; } if($Functional[$i]==2){ $Functional[$i] = "Construction,engineering"; } if($Functional[$i]==3){ $Functional[$i] = "Retail"; } if($Functional[$i]==4){ $Functional[$i] = "Sales, BD"; } if($Functional[$i]==5){ $Functional[$i] = "Insurance"; } if($Functional[$i]==6){ $Functional[$i] = "Site Engineering"; } if($Functional[$i]==7){ $Functional[$i] = "Web, Graphic Design"; } if($Functional[$i]==8){ $Functional[$i] = "Telecom"; } if($Functional[$i]==9){ $Functional[$i] = "Oil, Energy, Power"; } if($Functional[$i]==10){ $Functional[$i] = "Pharma, Biotech"; } if($Functional[$i]==11){ $Functional[$i] = "Marketing"; } if($Functional[$i]==12){ $Functional[$i] = "Media, Entertainment"; } if($Functional[$i]==13){ $Functional[$i] = "Purchase, Supply Chain"; } if($Functional[$i]==14){ $Functional[$i] = "TV Films"; } if($Functional[$i]==15){ $Functional[$i] = "Banking, Financial Services"; } if($Functional[$i]==16){ $Functional[$i] = "Automobiles"; } if($Functional[$i]==17){ $Functional[$i] = "Hospitality"; } if($Functional[$i]==18){ $Functional[$i] = "HR, Admin"; } if($Functional[$i]==19){ $Functional[$i] = "IT-Hardware, Telecom"; } if($Functional[$i]==20){ $Functional[$i] = "Architecture, Interior Design"; } if($Functional[$i]==21){ $Functional[$i] = "Fashion Garments"; } if($Functional[$i]==22){ $Functional[$i] = "BPO, KPO"; } if($Functional[$i]==23){ $Functional[$i] = "Industrial Products"; } if($Functional[$i]==24){ $Functional[$i] = "Overseas, International"; } if($Functional[$i]==25){ $Functional[$i] = "Accounts, Finance"; } if($Functional[$i]==26){ $Functional[$i] = "Manufacturing"; } if($Functional[$i]==27){ $Functional[$i] = "Content, Journalism"; } if($Functional[$i]==28){ $Functional[$i] = "Top Management"; } } $FunctionalIn = serialize($Functional); print $Industry = $_POST["Industry"]; $IndustryIn = serialize($Industry); // echo "File is valid, and was successfully uploaded.\n"; $str =" resume_path,jobseeker,resume,dob,gender,qualificat ion1,coursename1,coursetype1,specification1,instit ute1,passout1,qualification2,coursename2,coursetyp e2,specification2,institute2,passout2,qualificatio n3,coursename3,coursetype3,specification3,institut e3,passout3,expyear,expmonth,Functional,Industry,p referedcountry1,preferedstate1,preferedcity1,prefe redcountry2,preferedstate2,preferedcity2,preferedc ountry3,preferedstate3,preferedcity3,rupees,dollar ,tags,jobtitle,copypaste,skills"; $str1 = "'$uploadfile','".$_SESSION["id"]."','".$_POST["Resume22"]."','$dob','$gender','$qual1','$coname1','$cotype1 ','$spec1','$institute1','$passout1','$qual2','$co name2','$cotype2','$spec2','$institute2','$passout 2','$qual3','$coname3','$cotype3','$spec3','$insti tute3','$passout3','$expyear','$expmonth','$Functi onalIn','$IndustryIn','$preferedcountry1','$prefer edstate1','$preferedcity1','$preferedcountry2','$p referedstate2','$preferedcity2','$preferedcountry3 ','$preferedstate3','$preferedcity3','$rupees','$d ollar','$tags','$jobtitles','$copypaste','$skills' "; $query = "insert into jobseekerstep2($str)values($str1)"; $res = mysql_db_query('vigrav',$query); }else{ echo 'file is invalid'; } }else { $str ="resume_path,jobseeker,resume,date,month,year,gen der"; $str1 = "'$uploadfile','".$_SESSION["jobid"]."','','$date','$month','$year','$gender'"; $query = "insert into jobseekerstep2($str)values($str1)"; $res1 = mysql_db_query('vigrav',$query1); if($res1){ echo 'ok'; }else{ echo 'not ok '; mysql_error(); } } } if($_REQUEST["up"] == "res"){ // upload yr photo // $uploaddir = 'C:/wamp/www/vijay/mov_img/'; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); // upload yr ten certifiacte // $uploaddir1 = "C:/wamp/www/vijay/mov_ten/"; $uploadfile1 = $uploaddir1 . basename($_FILES['tenfile']['name']); // upload yr ten certifiacte // $uploaddir2 = "C:/wamp/www/vijay/mov_degree/"; $uploadfile2 = $uploaddir2 . basename($_FILES['degreefile']['name']); if($_FILES['userfile']['name']!="" && $_FILES['tenfile']['name']!="" && $_FILES['degreefile']['name']!=""){ if(copy($_FILES['userfile']['tmp_name'], $uploadfile) && copy($_FILES['tenfile']['tmp_name'], $uploadfile1) && copy($_FILES['degreefile']['tmp_name'], $uploadfile2) ) { echo "File is valid, and was successfully uploaded.\n"; echo $query = "insert into jobseeker1(img_path,ten_path,degree_path,jobseeker )values('$uploadfile','$uploadfile1','$uploadfile2 ','')"; $res = mysql_query($query); }else{ //echo 'file is invalid'; } } } mysql_close($link); ?> |
my eyes are hurting thank you for that
PHP Code:
PHP Code:
$expyear = $_POST["expyear"]; is exactly the same thing as $_POST["expyear"]; http://roshanbh.com.np/2007/12/clean...ue-in-php.html |
first of all, instead of doing this
$link = mysql_connect("localhost",... etc) if(!$link) { bla bla } there is a better way. you do this. Code:
as for the rest, try not to use the session function. although there might be a debate on this lol. but i would suggest not to use it and use cookies instead. |
sarmen: That's not always a better way. The first method allows you to incorporate your own error handling as well as continue to execute the script/current page if you so desire. In addition, in a live environment, echoing sensitive error information directly to the browser can provide potential mischief makers with important information about your backend.
Also, just out of curiousity, why not use the built-in session functionality of PHP? It's really quite useful, and IIRC session data is stored locally on the server so it's actually more reliable than straight client-side cookies. -m |
| All times are GMT. The time now is 09:03 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0