Jump to content

need some help please


rasheedn

Recommended Posts

hi, i've built a website with a mysql db
i;ve got a few problems that i need some help with

1.
<input type="text" name="Post_code" size="26" value = <? echo $Post_code;?>></td>

in the above code, if $Post_code has a space it won't echo anything after the space! cant' figure out why!
example, if $Post_code = "sw1 4ts" , then the output will be only "sw1" without the rest!!

2.
is there a function like echo but instead of outputting something on the screen i want it to move to another page! without me having to click on anything !
i've got like a validation on an entry, and if its valid i want it to load a new page (loaclhost/newfolder/testing1.php) as an example

i've done it in a different way for now and it works but with a slight problem !!hehe

i've created a function to output testing1.php! and once the validation is complete i just call the function. now this works fine except the buttons dont' work anymore!(the buttons on testing1.php) (they work fine if i open testing1.php)

i've been trying to fix this for a whole day and i've lost hope!!
any help would be greatly appreciated

sorry if my english is crap! hope u understood what i mean:)

thanks

Rasheed
Link to comment
Share on other sites

For number one, put double quotes around the value

ie: <input type="text" name="Post_code" size="26" value="<? echo $Post_code;?>"></td>

For number two you will need to be more specific, give a code example of what you have done. sound like it might be more of a javascript issue than php
Link to comment
Share on other sites

Sanfly Thanks that " " worked perfect :)

as for 2 here's some code that i hope will explain....
i have 4 files
2 normal php files
and 2 files that have the code to display the forms and page

its a 2 page website (main page and service page)


***********1st file (main_page_forms.php)**********

.....

function m_p((&$PHP_SELF, $First_name, $Last_name, $Address, $Post_code ...){

here i have a couple of these
<input type="text" name="First_name" size="27" value = "<? echo $First_name;?>"></td>
and 4 buttons
like this

<form name ="otherbuttons" action="<?php echo ($PHP_SELF)?>"METHOD=POST>
<input name="Service_details" type="submit" style="color: #FF0000" value="Service Details"></td>
<td width="70" height="27">
<input type="submit" value="Save" name="save"></td>
<td width="314" height="27">
<input type="submit" value="Search" name="search">
<input name="clear" type="reset" onClick="MM_goToURL('parent','testing5.php');return document.MM_returnValue" value="Clear"></td>
}



*******2nd file is the main page itslef (main_page.php)**********

include("main_page_forms.php");
include("dbinfo.inc.php");
.....

if($_GET['Cust_id']){// this will display the search results

$Cust_idd= $_GET['Cust_id'];
mysql_connect(localhost,$username,$password);
mysql_select_db($database) or die( "Unable to select database");

$sql = ("SELECT `Cust_id` , `First_name` , `Last_name` , `Address` , `Post_code` , `Phone_number` , `Mobile_number` , `Number_plate` , `Car` , `Model` , `Year` , `Mot_exp`
FROM `customer`
WHERE 1 AND `Cust_id` = '$Cust_idd' ");

$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$Cust_id = $myrow[Cust_id];
$First_name = $myrow[First_name];
$Last_name = $myrow[Last_name];
$Address = $myrow[Address];
$Post_code = $myrow[Post_code];
$Phone_number = $myrow[Phone_number];
$Mobile_number = $myrow[Mobile_number];
$Number_plate = $myrow[Number_plate];
$Car = $myrow[Car];
$Model = $myrow[Model];
$Year = $myrow[Year];
$Mot_exp = $myrow[Mot_exp];

$_SESSION['Cust_id'] = $Cust_id;
$temp = main_page_wv(&$PHP_SELF , $First_name , $Last_name , $Address , $Post_code , $Phone_number , $Mobile_number , $Number_plate , $Car , $Model , $Year , $Mot_exp);
$result2 = mysql_query("SELECT `Cust_id` , `History_id` , `Serv_date` , `Short_desc` , `Mot` , `Serv_details` , `Part_charge` , `Labor` , `Mot_charge`
FROM `service`
WHERE 1 AND `Cust_id` = '$Cust_id'");
$howmanyrows2=mysql_num_rows($result2);
$myrow2 = mysql_fetch_array($result2);


do { //print the history for the current user

echo "<a href=\"".$PHP_SELF."?History_id=".$myrow2["History_id"]."\">".$myrow2["Serv_date"]." - ".$myrow2['Short_desc']."</a><br>";
echo "<br />\n";

} while ($myrow2 = mysql_fetch_array($result2));

}else if($_POST[search]){ //if clicked on the search button

extract($_POST);
mysql_connect(localhost,$username,$password);
mysql_select_db($database) or die( "Unable to select database");


$result = mysql_query(" SELECT `Cust_id` , `First_name` , `Last_name` , `Address` , `Post_code` , `Phone_number` , `Mobile_number` , `Number_plate` , `Car` , `Model` , `Year` , `Mot_exp`
FROM `customer`
WHERE 1 AND `First_name`
LIKE '$First_name' OR `Last_name`
LIKE '$Last_name' OR `Post_code`
LIKE '$Post_code' OR `Number_plate`
LIKE '$Number_plate'");

$howmanyrows =mysql_num_rows($result);

if ($howmanyrows == 1){

$myrow = mysql_fetch_array($result);
do {
$Cust_id = $myrow[Cust_id];
$First_name = $myrow[First_name];
$Last_name = $myrow[Last_name];
$Address = $myrow[Address];
$Post_code = $myrow[Post_code];
$Phone_number = $myrow[Phone_number];
$Mobile_number = $myrow[Mobile_number];
$Number_plate = $myrow[Number_plate];
$Car = $myrow[Car];
$Model = $myrow[Model];
$Year = $myrow[Year];
$Mot_exp = $myrow[Mot_exp];
main_page_wv(&$PHP_SELF , $First_name , $Last_name , $Address , $Post_code , $Phone_number , $Mobile_number , $Number_plate , $Car , $Model , $Year , $Mot_exp);

$result2 = mysql_query("SELECT `Cust_id` , `History_id` , `Serv_date` , `Short_desc` , `Mot` , `Serv_details` , `Part_charge` , `Labor` , `Mot_charge`
FROM `service`
WHERE 1 AND `Cust_id` = '$Cust_id'");
$howmanyrows2=mysql_num_rows($result2);
$myrow2 = mysql_fetch_array($result2);


do { //print the history for the current user

echo "<a href=\"".$PHP_SELF."?History_id=".$myrow2["History_id"]."\">".$myrow2["Serv_date"]." - ".$myrow2['Short_desc']."</a><br>";
echo "<br />\n";

} while ($myrow2 = mysql_fetch_array($result2));


} while ($myrow = mysql_fetch_array($result));
$_SESSION['Cust_id'] = $Cust_id;


}else if (($myrow = mysql_fetch_array($result))and ($howmanyrows >1)) {


main_page_wv(&$PHP_SELF , $First_name , $Last_name , $Address , $Post_code , $Phone_number , $Mobile_number , $Number_plate , $Car , $Model , $Year , $Mot_exp);

echo "Search Results :<br /><br /> ";

do {

echo "<a href=\"".$PHP_SELF."?Cust_id=".$myrow["Cust_id"]."\">".$myrow["First_name"]." ".$myrow['Last_name']." "." - ".$myrow['Address']." - ".$myrow['Post_code']." - ".$myrow['Car']." - ".$myrow['Model']."</a><br>";
echo "<br />\n";

} while ($myrow = mysql_fetch_array($result));



}else{ //nothing found

main_page_wv(&$PHP_SELF , $First_name , $Last_name , $Address , $Post_code , $Phone_number , $Mobile_number , $Number_plate , $Car , $Model , $Year , $Mot_exp);

echo "Sorry but nothing is found!";


}
}else if($_POST[Service_details]){

and here a couple of validation things to make sure all items have been entered
and the last one i want it to load (service_details.php) !!
i can't find a function to do that!
}}






******3rd file is the service page forms(service_page_forms.php)******

function service_page(&$PHP_SELF , $Serv_date,$Short_desc,.....)

and a few inputs like
<td width="283" colspan="2"><input type="text" name="Serv_date" size="20"value = <? echo $Serv_date;?>></td>

and forms...
<form action="<?php echo ($PHP_SELF)?>"METHOD=POST>
<input type="submit" name="Save" value="Save">
<input name="p_invoice" type="submit" onClick="MM_callJS('javascript:print()')" value="Print Invoice">
<input name="clear2" type="reset" onClick="MM_goToURL('parent','servicedetails2222.php');return document.MM_returnValue" value="Clear"></td>
<td height="50" width="134">
<input name="mainpage" type="submit" onClick="MM_goToURL('parent','testing5.php');return document.MM_returnValue" value="Main Page"></td>
}



**************4th file is the Service page itself(service_page.php)***************

include ("service_page_forms.php");

deals with the service page buttons...





in the 2nd file as you can see if i click on the search button and 2 items are found then i display the results as a link to the main page with ?custid=id! and i got another if statement at the top to load the page to load the main page using the custid! once the page is loaded tho non of the button work!!(except the clear!!)
and this is the problem i have!

i hope this makes sense!!
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.