0

aspがフォームの値を引き継いで、別のリンクされたページにプラグインできることを私は知っています。PHPPDOスクリプトでこれを行う方法はありますか?たとえば、モックサイトに新しいメンバーごとに新しいテーブルエントリがあります。レコードごとに、同じ行のメンバーの値を持つ「メンバープロファイル」と呼ばれるフォームボタンが作成されます。ボタンをクリックすると、メンバー名を新しいページに移動し、そのphpmyadminテーブルにリンクして、そのメンバーのすべての日付を表示します。私はその権利を説明したと思います。これが私のコードです

$dsn = 'mysql:host=localhost;dbname=averyit_net';
$db_username = "root";
$db_password = "password";


$db = new PDO ($dsn, $db_username, $db_password);

$tablemaker = $db->query("SELECT `cust_profile`.`CustomerName`,                 
`cust_profile`.`CustomerType`, `cust_profile`.`ContractHours` FROM `cust_profile` ORDER       
BY    `CustomerName`");
while ($rows = $tablemaker->fetch(PDO::FETCH_ASSOC)) {

?>
<table width="75%"  border="1" cellspacing="0" align="center">
<th width="15%" height="0%" bgcolor="#819FF7"> </th>
<th width="35%" height="0%" bgcolor="#819FF7"> </th>
<th width="30%" height="0%" bgcolor="#819FF7"> </th>
<th width="20%" height="0%" bgcolor="#819FF7"> </th>
<tr> 

<form method="post" action="edit_cust.php" >
  <td align="center"> 
    <span style="font-size: 9pt"><font size="1" face="Verdana">
        <input TYPE="submit" NAME="dothis0" value="Customer Profile">      
</font></span><font face="Verdana"><font size="2">
    </font>
    <input type="hidden" name="custID" value="<?php echo $rows['CustomerName']; ?>">
    </font>
  </td>
</form>
4

2 に答える 2

0
change method="post" to method="get"

on your second form you will be posted a url like this (ie):

script.php?your_variable=lorem&second_variable=ipsum

<input type="text" value="<?=($_GET['your_variable']) ? htmlentities($_GET['your_variable']) : ''?>" name="field_name">

<input type="text" value="<?=($_GET['second_variable']) ? htmlentities($_GET['second_variable']) : ''?>" name="field_name">
于 2013-03-26T03:27:57.227 に答える
0

フォームを変更した後method="get"

フォームを送信すると、にリダイレクトされますaction="edit_cust.php"

CustomerNameこれにより、このようなパラメータを含むURLが生成されます

* www.localhost / website / edit_cust.php?name = Me *

次に、$ _ GET []グローバル変数を使用して、edit_cust.phpでそのデータを取得または使用できます。

// set it to variable..
$CustomerName = $_GET['name'];
//note: your $_GET[] parameter should equal to what is in your url to gets its value...

そうすれば、変数を使用して顧客名を使用できるようになります$customerName

于 2013-03-26T03:37:37.563 に答える