Complete coding noob with a silly problem!
Posted: Mon Feb 01, 2010 10:41 pm
right, this is probably going to be the most messy implimentation to ever cross these board but I'm afraid I'm a complete noob and it's showing!
What I've got at the moment is one page which has a for on it passing information to another page which runs the query to add infor into a MySQL database...
Index.html with the form:
I've left out the rest of the page bot obviously it exists, just didn't think anyone would be interested in it!!
Here's the include.php file:
There's an HTML redirect at the bottom of this page to return people to the first page once the record has been entered (like I said, I'm a noob!)
So far, this all works, it does what it says on the tin as it were. What I'd like to do is provide a URL someone could have a link to which would pass data straight to the include.php file without the need to open the index page (the form is time consuming and it's a quick shortcut for users) The problem is, I have no idea how to do it!
I've tried what I believe is the standard PHP way of passing varaibles in the URL which was:
http://wncp3400/calls/calls/include.php ... Logged=Yes
and all that happens is I get a blank entry in the MySQL database. I've tried a few variations on the theme but I'm really just shooting in the dark with it. Could anyone lend a hand?
What I've got at the moment is one page which has a for on it passing information to another page which runs the query to add infor into a MySQL database...
Index.html with the form:
Code: Select all
<FORM name="Survey" method=post action="include.php" onSubmit="return checkrequired(this)">
<tr>
<td colspan='3'>
<img src='images/spacer.png' /></td>
</tr>
<TR>
<TD width="260" align='center'>
<span class='questions'>Was a call logged?</span><br />
<SELECT class='Jumpbox' name='requiredLogged'>
<OPTION selected></OPTION>
<OPTION VALUE='Yes'>Yes</OPTION>
<OPTION VALUE='No'>No</OPTION>
</SELECT></TD>
<TD width="127" align="center">
<span class='questions'>Was a call updated?</span><br />
<SELECT class='Jumpbox' name='requiredUpdated'>
<OPTION selected></OPTION>
<OPTION VALUE='Yes'>Yes</OPTION>
<OPTION VALUE='No'>No</OPTION>
</SELECT></TD>
<TD width="205" align='center'>
<span class='questions'>Call Number</span><br />
<INPUT class='text' type=text name='Incident'></TD>
</TR><tr>
<td colspan='3'>
<img src='images/spacer.png' /></td>
</tr><TR>
<TD align='center'>
<span class='questions'>Who Took The Call</span><br /><br />
<SELECT class='Jumpbox' name='requiredAnalyst'>
<OPTION selected></OPTION>
<?php
include 'connect.php';
$sql="SELECT user FROM login
Order by user";
$result =mysql_query($sql);
while ($data=mysql_fetch_assoc($result)){
?>
<option value ="<?php echo $data['user'] ?>"><?php echo $data['user'] ?></option>
<?php } ?>
</select>
<TD align='center' colspan='2'>
<span class='questions'>If 'Other' please specify:</span><br />
<TEXTAREA class='textarea' rows='3' name='AnalystOther'></TEXTAREA></TD>
</TR><tr>
<td colspan='3'>
<img src='images/spacer.png' /></td>
</tr><TR>
<TD align='center'>
<span class='questions'>Which Client Was The Call For?</span><br /><br />
<SELECT class='Jumpbox' name='requiredClient'>
<OPTION selected></OPTION>
<?php
include 'connect.php';
$sql="SELECT Clientname FROM client
Order by Clientname";
$result =mysql_query($sql);
while ($data=mysql_fetch_assoc($result)){
?>
<option value ="<?php echo $data['Clientname'] ?>"><?php echo $data['Clientname'] ?></option>
<?php } ?>
</SELECT></TD>
<TD align='center' colspan='2'>
<span class='questions'>If 'Other' Please Specify</span><br />
<TEXTAREA class='textarea' rows='3' name='ClientComments'></TEXTAREA></TD>
</TR><tr>
<td colspan='3'>
<img src='images/spacer.png' /></td>
</tr><TR>
<TD align='center'>
<span class='questions'>Type of Call:</span><br /><br />
<select class='Jumpbox' name='requiredCallType'>
<option selected></option>
<?php
include 'connect.php';
$sql="SELECT CallType FROM CallType
Order by CallType";
$result =mysql_query($sql);
while ($data=mysql_fetch_assoc($result)){
?>
<option value ="<?php echo $data['CallType'] ?>"><?php echo $data['CallType'] ?></option>
<?php } ?>
</select></TD>
<TD align='center' colspan='2'>
<span class='questions'>Provide Further Details if Possible:</span><br />
<TEXTAREA class='textarea' rows='3' name='FurtherDetails'></TEXTAREA></TD>
</TR><tr>
<tr>
<td colspan='3'>
<img src='images/spacer.png' /></td>
</tr><TR>
<TD colspan='3' align='center'>
<span class='questions'>Is there anything else you would like to add?</span><br />
<TEXTAREA class='textarea' rows='3' name='FurtherComments'></TEXTAREA></TD>
</TR>
<tr>
<td colspan='3'>
<img src='images/spacer.png' /></td>
</tr>
<TR>
<TD align='center'><INPUT type='Reset' value='Reset'></TD>
<TD align='center' colspan='2'><INPUT type='submit' value='Send'><br /></TD>
</TR></form>Here's the include.php file:
Code: Select all
<?
//Connect to database
include 'connect.php';
//deifne variables
$Logged=$_POST['requiredLogged'];
$Updated=$_POST['requiredUpdated'];
$Incident=$_POST['Incident'];
$Analyst=$_POST['requiredAnalyst'];
$AnalystOther=$_POST['AnalystOther'];
$Client=$_POST['requiredClient'];
$ClientComments=$_POST['ClientComments'];
$CallType=$_POST['requiredCallType'];
$FurtherDetails=$_POST['FurtherDetails'];
$FurtherComments=$_POST['FurtherComments'];
//Define Query
$query = "INSERT INTO data(Logged, Updated, Incident, Analyst, AnalystOther, Client, ClientComments, CallType, FurtherDetails, FurtherComments)
VALUES ( '$Logged', '$Updated', '$Incident', '$Analyst', '$AnalystOther', '$Client', '$ClientComments', '$CallType', '$FurtherDetails', '$FurtherComments')";
//Run queries and error reporting
if (!mysql_query($query))
{
die('Error: ' . mysql_error());
}
?>
So far, this all works, it does what it says on the tin as it were. What I'd like to do is provide a URL someone could have a link to which would pass data straight to the include.php file without the need to open the index page (the form is time consuming and it's a quick shortcut for users) The problem is, I have no idea how to do it!
I've tried what I believe is the standard PHP way of passing varaibles in the URL which was:
http://wncp3400/calls/calls/include.php ... Logged=Yes
and all that happens is I get a blank entry in the MySQL database. I've tried a few variations on the theme but I'm really just shooting in the dark with it. Could anyone lend a hand?