php - Mysql Insert form into database table PDO -
i have problem.. tried today lot make working seems impossible me.. decided ask here. have form needs added on database table when submit button pressed. php code use.. removed tries btw:
<?php $pdo = new pdo('mysql:host=;dbname=', '', ''); $sql = "select * games limit 10"; foreach ($pdo->query($sql) $row) { ?>
my html code (form):
<form class="form-group" method="post" action=""> <div role="tabpanel" class="tab-pane active" id="home"> <div class="form-group" style="margin-top: 15px;"> <label for="exampleinputemail1">game title</label> <input type="text" class="form-control" id="exampleinputemail1" placeholder="" name="gtitle" /> </div> <div class="form-group"> <label for="exampleinputpassword1">youtube link</label> <input type="text" class="form-control" id="exampleinputpassword1" placeholder="" name="ytlink" /> </div> <div class="form-group"> <label for="exampleinputpassword1">link source</label> <input type="text" class="form-control" id="exampleinputpassword1" placeholder="ex: gleam, dlh, failmid, hrkgame, indiegala, other, steam" name="slink" /> </div> <div class="form-group"> <label for="exampleinputpassword1">link free steam keys</label> <input type="text" class="form-control" id="exampleinputpassword1" placeholder="key must give +1 steam library game count" name="keysl" /> </div> <label for="exampleinputpassword1">steam app id</label> <div class="input-group" style="padding-bottom: 10px;"> <span class="input-group-addon" id="basic-addon3">http://store.steampowered.com/app/</span> <input type="text" class="form-control" id="basic-url" aria-describedby="basic-addon3" placeholder="app id" name="appid" /> </div> <div class="form-group"> <label for="exampleinputpassword1">categories</label> <div class="checkbox"> <label class="radio-inline"> <input type="radio" name="inlineradiooptions" id="inlineradio1" value="option1" /> 1 <h4><span class="label label-success">keys available</span></h4> </label> <label class="radio-inline"> <input type="radio" name="inlineradiooptions" id="inlineradio2" value="option2" /> 2 <h4><span class="label label-danger">no keys left</span></h4> </label> </div> <button type="submit" class="btn btn-default" name="insert">submit</button> </div> </div> </form>
thank me.
try , in radio button put value '1' , '2' instead of 'option1' , 'option2'
if(isset($_post['insert'])) { $game_title=$_post['gtitle']; $youtube_link=$_post['ytlink']; $link_source=$_post['slink']; $link_steam_keys=$_post['keysl']; $app_id=$_post['appid']; $categories=$_post['inlineradiooptions']; $query_ins="insert tbl_game(game_title,youtube_link,link_source,link_steam_keys,app_id,categories) values(:game_title,:youtube_link,:link_source,:link_steam_keys,:app_id,:categories)"; $stmt_query=$dbh->prepare($query_ins); $games_ins=$stmt_query->execute(array(":game_title"=>$game_title,":youtube_link"=>$youtube_link,":link_source"=>$link_source,":link_steam_keys"=>$link_steam_keys,":app_id"=>$app_id,":categories"=>$categories)); if(!$games_ins) { $error=$stmt_query->errorinfo(); echo $error['2']; } }
Comments
Post a Comment