Jump to content

[SOLVED] need help to enter values


contra10

Recommended Posts

i'm having trouble entering 2 values that are get values from another page heres my code

 

<?php
mysql_connect("localhost", "root", "") or die(mysql_error()); 
mysql_select_db("registration") or die(mysql_error());

if(is_numeric($_GET['id'])){

$id = $_GET['id'];

  $insert1= "SELECT * FROM groups WHERE id = '$id'";
$topic1 = mysql_query($insert1) or die(mysql_error());

while ($topica = mysql_fetch_assoc($topic1))
{
$grpname= "{$topica['name']}";
}
} 

//This code runs if the form has been submitted
if (isset($_POST['submit'])) { 

//This makes sure they did not leave any fields blank
if (!$_POST['name'] | !$_POST['note']) {
die('You did not complete all of the required fields');
}

// checks if the name is in use
if (!get_magic_quotes_gpc()) {
$_POST['name'] = ($_POST['name']);
}
$topiccheck = $_POST['name'];
$check = mysql_query("SELECT notename FROM notes_groups WHERE notename = '$topiccheck'") 
or die(mysql_error());
$check2 = mysql_num_rows($check);

//if the name exists it gives an error
if ($check2 != 0) {
die('Sorry, the topic '.$_POST['name'].' is already in use.');
}

// this makes sure both name and group entered match
if ($_POST['name'] == $_POST['note']) {
die('Input a different name please. ');
}

$query2= "SELECT id FROM users WHERE username = '$username'";
$result2 = mysql_query($query2) or die(mysql_error());;
$usera = mysql_fetch_assoc($result2);
$userid = "{$usera['id']}";

$name = mysql_real_escape_string($_POST['name']);
$note = mysql_real_escape_string($_POST['note']);
$link = mysql_real_escape_string($_POST['link']);

//This gets today's date 
$date = time () ; 


//This puts the day, month, and year in seperate variables 
$day = date('d', $date) ; 
$month = date('F', $date) ; 
$year = date('Y', $date) ;

// now we insert it into the database
$insert = "INSERT INTO notes_groups (gid, gname, uid, uname, notename, note, link, month, day, year)
VALUES ('$id', '$grpname', '$userid', '$username', '$name', '$note', '$link', '$month', '$day', '$year')";
$add_group = mysql_query($insert) or die(mysql_error());	

?>

 

the values $id and $grpname do not enter, but they are on the page as before i echoed thevalues on that same page. So i know that they are on the page

Link to comment
Share on other sites

change this line

 

$insert = "INSERT INTO notes_groups (gid, gname, uid, uname, notename, note, link, month, day, year)
VALUES ('$id', '$grpname', '$userid', '$username', '$name', '$note', '$link', '$month', '$day', '$year')";
$add_group = mysql_query($insert) or die(mysql_error());]

 

to

$insert = "INSERT INTO notes_groups (gid, gname, uid, uname, notename, note, link, month, day, year)
VALUES ('$id', '$grpname', '$userid', '$username', '$name', '$note', '$link', '$month', '$day', '$year')";
die($insert);
$add_group = mysql_query($insert) or die(mysql_error());

 

and see what you get back

Link to comment
Share on other sites

looks like these values are not even being passed - with all the $_POST in there it would seem you have neglected to correctly insert the values into the action attribute of the submittng form...

 

- May I suggest you stick to one form of datatransfer and simply put these values in hidden fields within that form????

 

post back your form html as well as the code if you have investigated this aspect and are still having problems...

 

PS http://www.pastebin.com can be really helpful in these situations....

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.