SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    select element on form not inserting values in table

    all other element are inserting the values inputed in the table except the select element, i have also echoed it but it returns no value,
    below it the related php and html form.please help have a look,thanks

    PHP Code:
    <?php
    $submit 
    $_POST['Add'];

    //form data
    $Sname strip_tags(htmlentities($_POST['Sname']));
    $Pname strip_tags(htmlentities($_POST['Pname']));
    $Pidno strip_tags(htmlentities($_POST['Pidno']));
    $Psize strip_tags(htmlentities($_POST['Psize']));
    $Pcolour strip_tags(htmlentities($_POST['Pcolour']));
    $Pquantity $_POST['Pquantity'];
    $Weblink strip_tags(htmlentities($_POST['Weblink']));
    $Price strip_tags(htmlentities($_POST['Price']));

    echo 
    "$Pquantity","$Pname";

    if(
    'POST' === $_SERVER['REQUEST_METHOD']) 

    {
    //open database
    $connect mysql_connect('localhost','xxxxxx','xxxxxxx') or die('error connecting: ' mysql_error());
    mysql_select_db('reachea2_registeringmembers')or die('error selecting db: ' mysql_error());//select database
    //check for pplac
        //if ($Sname&&$Pname)
    //{
    $queryreg mysql_query("

    INSERT INTO repplac VALUES ('','
    $Sname','$Pname','$Pidno','$Psize','$Pcolour','$Pquantity','$Weblink','$Price')

    "
    );
    //}

    }
    ?>
    HTML Code:
    <form action='youraccount.php' method='Post' class='slistbar'>
    	<!--<div>
    	<label for='shoppinglist' class='fixedwidth'></label>
    	<textarea type='text' name='shoppinglist' id='username' cols='100' rows='15'></textarea>
    	</div> -->
    	
    	<div>
    	<label for='Sname' class='fixedwidth'>Shop name</label>
    	<input type='text' name='Sname' id='Sname'/>
    	</div>
    	<div>
    	<label for='Pname' class='fixedwidth'>Product name</label>
    	<input type='text' name='Pname' id='Pname'/>
    	</div>
    	<div>
    	<label for='Pidno' class='fixedwidth'>Product id no</label>
    	<input type='text' name='Pidno' id='Pidno'/>
    	</div>
    	<div>
    	<label for='Psize' class='fixedwidth'>Product size</label>
    	<input type='text' name='Psize' id='Psize'/>
    	</div>
    	<div>
    	<label for='Pcolour' class='fixedwidth'>Product colour</label>
    	<input type='text' name='Pcolour' id='Pcolour'/>
    	</div>
    	<div>
    	<label for='Pquantity' class='fixedwidth'>Product quantity</label>
    	<select name="pquantity" id="Pquantity">
    	  <option>1</option>
      	  <option>2</option>
      	  <option>3</option>
      	  <option>4</option>
      	  <option>5</option>
      	  <option>6</option>
      	  <option>7</option>
      	  <option>8</option>
      	  <option>9</option>
      	  <option>10</option> 
    </select>
    	</div>
    	<div>
    	<label for='Weblink' class='fixedwidth'>Web link</label>
    	<input type='text' name='Weblink' id='Weblink'/>
    	</div>
    	<div>
    	<label for='Price' class='fixedwidth'>Price GBP</label>
    	<input type='text' name='Price' id='Price'/>
    	</div>
    	<div class='buttonarea'>
    			<p>
    			<input type='submit' name='submit' value='Add'>
    			</p>
    			</div>
    			</p>
    	</form>

  2. #2
    Non-Member Max Height's Avatar
    Join Date
    Dec 2011
    Posts
    303
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    echo the actual query being run.

    "INSERT INTO repplac VALUES ('','$Sname','$Pname','$Pidno','$Psize','$Pcolour','$Pquantity','$Weblink','$Price')"

    and if the values are not correct then you need to trace back your code to the line where that incorrect value is set and fix it.

    hint: names are case sensitive

  3. #3
    SitePoint Addict
    Join Date
    Oct 2010
    Posts
    323
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    thanks i did that , and was able to track where the problem was in the code


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •