473,513 Members | 2,561 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Database Issue

39 New Member
I have this code and I when the submit button is pressed it will create a new record in the database but wont place any of the data from the form into the new record.? Im kind stumped.

This is what the http link looks like when I pull the page up.

[html]
/mailsend.php?iid=1
[/html]

This tells the following code which person I am sending a message to.

[php]
<?
include('db.php');
if ($myID == 0) header("location:login.php");
if ($admin == 0) header("location:login.php");

include("navtop.php");
include("nav.php");
include("func.php");
connect1();



// this is where I take the data and insert it into the database
_v('mode;i:id');
if ($mode=='save'){
pg('msg_from,msg_to,msg_body,msg_date,msg_time,msg _subject,msg_subject,msg_isread,msg_sid,msg_tid');
$qupd = mysql_query("INSERT INTO `email` VALUES ('0','$name', '$to', '$msg', '$now', '$t', '$subject','0','$myId','$iid')") or die(mysql_error());
goto('mail.php');
}

$now = date('m/d/Y');
$t = date('h:i A');


// this is the query that gets the current loged in user and data about him or her

$query = mysql_query("SELECT * FROM `instructors` WHERE id='$myID'") or die(mysql_error());
$row = mysql_fetch_array($query);
extract($row);
$name = $row['first_name'] . " " . $row['last_name'];


echo "<td width=100% valign=top>
<table border=0 width=100% class=leftMenutop1><td>

</form>
<form method='post' name='frmado' action='mailsend.php'>
<table border=0 width=99% cellpadding=0 cellspacing=0>
<Td wdith=100%>";

// this is the query that pulls the selected person from the list out of the database
// this data displays just fine on the page

$qi = mysql_query("SELECT * FROM `instructors` WHERE id='$iid'");
$Row2 = mysql_fetch_array($qi);
extract($row);
$to = $row2['first_name'] . " " . $row2['last_name'];
echo "

<p><br><p><span class='text'>From: <b>$name</b></p>

<p><span class='text'>To: <b>$first_name $last_name</b></p>


<p><span class='text'>Subject<br>
<input type='text' size='50' name='subject' value='' id='subject' />
</p>

<p><span class='text'>Enter Message<br>
<textarea name='msg' id='msg' cols=50 rows=15 value=''></textarea>

<input type='hidden' name='mode' value='save'>
<p><input type=submit name='submit' value='Send Message' class='input' ></p>


</td>
</table>";

include('navbot.php');

?>
[/php]
Apr 4 '08 #1
10 1294
hsriat
1,654 Recognized Expert Top Contributor
When a variable is posted to a PHP page, it not posted as $name, but as $_POST['name']

Change all your variables to the form of $_POST['variable_name']

Also, use the closing form tab at right position.

Harpreet
Apr 4 '08 #2
nathanwb
39 New Member
When a variable is posted to a PHP page, it not posted as $name, but as $_POST['name']

Change all your variables to the form of $_POST['variable_name']

Also, use the closing form tab at right position.

Harpreet

Even though is posting to the same file?
Apr 4 '08 #3
hsriat
1,654 Recognized Expert Top Contributor
Actually, It doesn't matter which file it is posting to.

Each time you call the same file, it has no link to the previously called one.
Also when you click on the submit button, it calls the same script again and doesn't start from where it left last time.

So you would need to make that change.


Regards,
Harpreet
Apr 4 '08 #4
nathanwb
39 New Member
Actually, It doesn't matter which file it is posting to.

Each time you call the same file, it has no link to the previously called one.
Also when you click on the submit button, it calls the same script again and doesn't start from where it left last time.

So you would need to make that change.


Regards,
Harpreet
Ok, just so I understand.. were would I place those quotes?
Apr 4 '08 #5
hsriat
1,654 Recognized Expert Top Contributor
Ok, just so I understand.. were would I place those quotes?
Which quotes?........
Apr 4 '08 #6
nathanwb
39 New Member
Which quotes?........

$_POST['variable_name']


were in the code..?
Apr 4 '08 #7
hsriat
1,654 Recognized Expert Top Contributor
I mean to say, replace all your variables which are posted by the form with $_POST['variable_name'].
Where variable_name is the name of the variable.

eg:
change:
$subject to $_POST['subject']
$msg to $_POST['msg']
$mode to $_POST['mode']
Apr 4 '08 #8
dlite922
1,584 Recognized Expert Top Contributor
$_POST['variable_name']


were in the code..?
Welcome to PHP $_POST 101, please have a seat, turn of your cell phones, and turn to page 1 in your booklet.

We have the following code that posts a field's text, if run in a browser, to another (or same) php file

[PHP]

<html>
<body>
<form name="myForm" action="testing.php" method="post">
<input type="text" name="something" value="" />
<input type="submit" value="submit" />
</form>
</body>
</html>

[/PHP]

Once the user types in a value in the text box and clicks submit.

the file in the action, testing.php can read the value in that text box like so

[PHP]
<?php

echo $_POST['something'];

?>
[/PHP]

any questions?
Apr 4 '08 #9
hsriat
1,654 Recognized Expert Top Contributor
Good work, professor DM!

:)


Regards,
Harpreet
Apr 4 '08 #10
coolsti
310 Contributor
*rubs eyes*

Am I missing something here? The original poster presented this line as the way he was getting data from the user interface to his script:

/mailsend.php?iid=1

This is telling me that he is not "POST"ing the variable, but sending it as part of the URL, so that the proper way to retrieve the variable is to use

$_GET['$name']

rather than

$_POST['$name']

Just so as not to confuse the OP if his variable is showing up in the $_GET array rather than the $_POST array.

/Steve, Denmark
Apr 4 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

16
7454
by: noah | last post by:
Does PHP have a feature to associate Cookie sessions with a persistent database connection that will allow a single transaction across multiple HTTP requests? Here is how I imagine my process: I...
6
2378
by: N. Graves | last post by:
Thank you for taking your time to read my question... please offer your knowledge it will be appreciated! I'm writing a ASP Web page to access a Access Database that has a Database Password set....
1
3996
by: Larry Dooley | last post by:
Here's my issue. We've decided to replace a very critical (without it the business would lose lots of money) departmental reporting system with a built from scratch system based on .NET. The key...
9
2194
by: Jerim79 | last post by:
I am no PHP programmer. At my current job I made it known that I was no PHP programmer during the interview. Still they have given me a script to write with the understanding that it will take me a...
1
3700
by: vbace2 | last post by:
I have searched this forum, and the web, and I have not been able to find a solution to my issue. I may not have used the right search information to find the answer, but I found a lot of issues...
0
7259
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7158
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7380
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7535
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5683
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.