473,671 Members | 2,578 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?ii d=1
[/html]

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

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

include("navtop .php");
include("nav.ph p");
include("func.p hp");
connect1();



// this is where I take the data and insert it into the database
_v('mode;i:id') ;
if ($mode=='save') {
pg('msg_from,ms g_to,msg_body,m sg_date,msg_tim e,msg_subject,m sg_subject,msg_ isread,msg_sid, msg_tid');
$qupd = mysql_query("IN SERT 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("SE LECT * FROM `instructors` WHERE id='$myID'") or die(mysql_error ());
$row = mysql_fetch_arr ay($query);
extract($row);
$name = $row['first_name'] . " " . $row['last_name'];


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

</form>
<form method='post' name='frmado' action='mailsen d.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("SE LECT * FROM `instructors` WHERE id='$iid'");
$Row2 = mysql_fetch_arr ay($qi);
extract($row);
$to = $row2['first_name'] . " " . $row2['last_name'];
echo "

<p><br><p><sp an class='text'>Fr om: <b>$name</b></p>

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


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

<p><span class='text'>En ter 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 1305
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

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

Similar topics

16
7497
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 have an series of interactive HTML forms. The user begins a Cookie session. A database connection is opened and a transaction is begun. After the user goes through any number of pages where they update the database they finish on a page where...
6
2385
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. If I remove the password I'm able to read and work with the database. Here is the code that I have to open the connection to the Database: Set objDB = Server.CreateObject("ADODB.Connection")
1
4000
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 component is a datagrid (it really turned the CIO's head). The issue is that the data source is Oracle. We've got a very complex reporting system that produces dynamic sql and sends it to oracle and takes back the result set and displays it. ...
9
2203
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 while (This information is just for general knowledge as I don't want anyone thinking I am trying to be dishonest with my intentions. Also, I do not portray myself as something I am not. I am a beginner.) Anyway, what the script needs to do is...
1
3714
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 close to mine, but nothing has helped. We are running Apache/2.2.4 (Win32) PHP/5.2.3. I am trying to use the odbc_connect to connect to an MS Access database that is on another server. I have tried to use both a system DSN, as well as putting the...
0
8481
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8823
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8602
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7441
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6234
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2817
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 we have to send another system
2
2058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.