473,387 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Issue with posting data to mysql table

I have this php code that I can get most of the data to post, but I am having a little bit of trouble..

I am passing the actualy student number to the page i.e. ?&id=1 this is used to pull the information from another table.

When I submit this data, it will post the time, date and the sender id... but nothing else is posted.

Here is the code.

[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();

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

_v('mode;i:id');
_v('msg_from,msg_to,msg_body,msg_date,msg_time,msg _subject,msg_isread,msg_sid,msg_tid');


if ($mode=='adds')
{
_v('msg_from,msg_to,msg_body,msg_date,msg_time,msg _subject,msg_isread,msg_sid,msg_tid');
$query = mysql_query("INSERT INTO email VALUES ('' ,'$from', '$to', '$msg', '$now', '$t', '$subject', '1', '$myID', '$tid')") or die(mysql_error());

echo " <br><br><br><Br> ";

goto('mail.php');
die();
}


$query = mysql_query("SELECT * FROM `instructors` WHERE id='$myID'");
$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='emailme.php'>

<table border=0 width=99% cellpadding=0 cellspacing=0>
<Td wdith=100%>";

$query = mysql_query("SELECT * from instructors WHERE id='$id'");
$Row = mysql_fetch_array($query);
extract($Row);
$tid = $Row['id'];
$name1 = $Row['first_name'] . " " . $Row['last_name'];

echo "


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


<p><span class='text'>To: <b>$name1 - $tid</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='to' value='$id'>
<input type='hidden' name='from' value='$name'>
<input type='hidden' name='mode' value='adds'>
<p><input type=submit name='submit' value='Send Message' class='input' >
</form>
</p>


</td>
</table>";



include('navbot.php');

?>
[/php]

Thank you
Apr 7 '08 #1
2 1482
TheServant
1,168 Expert 1GB
First of all, you don't have <tr> anywhere. Tables should be made like:
[HTML]<table>
<tr>
<td>
{content}
</td>
</tr>
</table>[/HTML]

Also, your form is all over the place?! U Start with echo-ing a </form>??? Why? I don't think these are the problems but it is very hard to troubleshoot when you need to work through bad html.

I have made some minor changes to the code, just so others can read it a bit better. Feel free to scan through and check what changes I have made so you can get an idea what I'm on about.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. include('db.php');
  3. if ($myID == NULL) header("location:login.php");
  4. if ($admin == NULL) header("location:login.php");
  5.  
  6. include("navtop.php");
  7. include("nav.php");
  8. include("func.php");
  9. connect1();
  10.  
  11. $now = date('m/d/Y');
  12. $t = date('h:i A');
  13.  
  14. _v('mode;i:id');
  15. _v('msg_from,msg_to,msg_body,msg_date,msg_time,msg_subject,msg_isread,msg_sid,msg_tid');
  16.  
  17.  
  18. if ($mode=='adds')
  19. {
  20.    _v('msg_from,msg_to,msg_body,msg_date,msg_time,msg_subject,msg_isread,msg_sid,msg_tid');
  21.    $query = mysql_query("INSERT INTO email VALUES ('' ,'$from', '$to', '$msg', '$now', '$t', '$subject', '1', '$myID', '$tid')") or die(mysql_error());
  22.  
  23. echo " <br><br><br><br> ";
  24.  
  25.    goto('mail.php');
  26.     die();
  27. }
  28.  
  29.  
  30. $query = mysql_query("SELECT * FROM instructors WHERE id='$myID'");
  31. $row = mysql_fetch_array($query);
  32. $name = $row['first_name'] . " " . $row['last_name'];
  33.  
  34. echo "
  35. <table border=0 width=100% class=leftMenutop1>
  36. <tr>
  37. <td>
  38. <form  method='post' name='frmado' action='emailme.php'>
  39.  
  40. <table border=0 width=99% cellpadding=0 cellspacing=0>
  41. <tr>
  42. <td wdith=100%>";
  43.  
  44. $query = mysql_query("SELECT * FROM instructors WHERE id='$id'");
  45. $Row = mysql_fetch_array($query);
  46. $tid = $Row['id'];
  47. $name1 = $Row['first_name'] . " " . $Row['last_name'];
  48.  
  49. echo "
  50. <p><br><p><span class='text'>From: <b>$name</b></p>
  51. <p><span class='text'>To: <b>$name1 - $tid</b></p>
  52. <p><span class='text'>Subject: <br>
  53. <input type='text' size='50' name='subject' value='' id='subject' />
  54. </p>
  55.  
  56. <p><span class='text'>Enter Message: <br>
  57. <textarea name='msg' id='msg' cols=50 rows=15 value=''></textarea>
  58.  
  59. <input type='hidden' name='to' value='$id'>
  60. <input type='hidden' name='from' value='$name'>
  61. <input type='hidden' name='mode' value='adds'>
  62. <p><input type=submit name='submit' value='Send Message'  class='input' ></p>
  63.  
  64. </td>
  65. </tr>
  66. </table>
  67.  
  68. </form>
  69.  
  70. </td>
  71. </tr>
  72. </table>";
  73.  
  74. include('navbot.php');
  75. ?>
  76.  
That is not complete, but your code needs some going through. Fix up those things and then we can move onto the real problem.
Apr 7 '08 #2
Atli
5,058 Expert 4TB
Hi.

You say that it does post the time, date and the sender id... I can't see <input> elements for any of those in your code. I suspect it has something to do with your _v() function... but I don't really know.

Is there something I'm not seeing here?

Also...
A couple of tips

Avoid using the <?...?> tags in your code. They are not enabled by default and can cause problems if you ever switch servers, or your current server is updated. Use <?php ... ?> instead. It's much safer ;)

I would also recommend against using the wild-card (*) in your SELECT queries. It will instruct your SQL server to return all columns, which will most likely transfer much more data than you actually use. Specify only the columns you need. It's just good practice ;)
Apr 7 '08 #3

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

Similar topics

0
by: Luc Foisy | last post by:
Last week many of our server and client servers had a power problem. Not = quite sure how the servers were handled, wasn't on site, but I don't = think some of these servers got shut down...
1
by: Mark Everett | last post by:
Hi, I am currently running out of space on one of my database servers. Is it possible to move the relevant files for tables onto another drive and instuct MySql to use both folders for it's...
1
by: Andrew | last post by:
Hello, Rather complicated one im afraid.. (well for me anyway!) Background on this one is that I have inherited a system that needs some modification, have some basic sql knowledge but fear i've...
8
by: Steve Jorgensen | last post by:
Hi folks, I'm posting this message because it's an issue I come up against relatively often, but I can't find any writings on the subject, and I haven't been able to figure out even what key...
0
by: Ike | last post by:
I have a MyISAM table where I am saving longblobs. These blobs are jpg files. However, when they are read back, there is a problem in that the jpg files "have two sof markers." I am wondering if...
1
by: mpar612 | last post by:
Hi everyone, I'm not sure if this is asking too much or not. I am trying to get the following PHP code to work on my website. It utilizes PHP 5, MySQL 4.1 and the PEAR DB module. I am...
30
by: nathanwb | last post by:
I am in the learning phase of PHP/Mysql thus my question :) I have a login.php page that passes the following values.. $myusername $mypassword. on submit it sends that data to a checklogin.php...
3
by: =?Utf-8?B?UGF1bCBQcmV3ZXR0?= | last post by:
I'm attempting to use LINQ to insert a record into a child table and I'm receiving a "Specified cast is not valid" error that has something to do w/ the keys involved. The stack trace is: ...
9
by: whitep8 | last post by:
Hi All, The following script will display the grid, with its headers but will not display any data. Im sure ive made a mistake in the syntax somewhere but i can see the wood for the trees. Ive...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...

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.