Welcome! Log In Create A New Profile

Advanced

insert page

Posted by 46564942-LASH 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
insert page
April 01, 2013 09:05AM
hi guys please help I'm trying to create the insert new player page but it returns blank values to the table
a copy of my code

<html>
<head>
<title>Add New Record in MySQL Database</title>

</head>
<body>

<?php


session_start();
$player_id="";
$fname_id="";
$sname_id="";
$Cnumber_id="";


include "connect.php";

$results=mysql_query("INSERT INTO tb_players (Name,Surename,Contact_number) VALUES ('$_POST[name]','$_POST[surname]','$_POST[contact_number]'winking smiley"winking smiley;
if($results){
$player="";
$fname=$_POST['name'];
$sname=$_POST["surename"];
$Cnumber=$_POST["contact_number"];

}
?>

<form method='POST' action='players.php'>
<table width="400" border="0" cellspacing="1" >
<tr>
<td>Player Name</td>
<td><input type="text" NAME="name" id="name" ></td>
</tr>
<tr>
<td> Surename</td>
<td><input name="surname" type="text" ></td>
</tr>
<tr>
<td>Contact number</td>
<td><input name="contact_number" type="text" ></td>
</tr>

<input type="submit" name="submit" value="Submit">
</td>
</tr>
</form>
</body>
</html>



PLEASE HELP!!!!!!!!!!!!!!!!!
avatar Re: insert page
April 03, 2013 02:37PM
First of all, don't post so much code on the site. I bet lots of people just copied it! When you do post code, use the code tags as instructed in the Tut101.
Please add quotes to your code to show what you want each section to do. It will make it easier for me and probably the lecturer to see if the code does what you think it would.

Like I have to guess this is where you are trying to add info to the session?
Language: PHP
session_start(); $player_id=""; $fname_id=""; $sname_id=""; $Cnumber_id="";

This bit below should be at the top of your page, even before the opening html tag to prevent the error that tells you header has already been sent.
Language: PHP
<php session_start(); ?>

This is just assigning empty strings to some variable. Make it clear what you are doing here.
Language: PHP
$player_id=""; $fname_id=""; $sname_id=""; $Cnumber_id="";

See how I put those in code sections? They look nice don't they? Comment the code a bit so that I can see what you want to do in each section. Can't guess what you were thinking smile

oh, and close your table tag

----------------------------------------------------------------------------------------

int get_random_number() {
return 4;
}
Sorry, only registered users may post in this forum.

Click here to login