Jump to content

Recommended Posts

Ive been working on a search feature for a school club. and i came across the URL parameter. I need to know how to create one  ??? i am very good in php but if this is a really easy concept dont flame me please. i have madwares.com/register/search.php it works until it tries to show the information which is at the results page. if any1 can help me here id appreciate it. (please don't register and spam my database.....)

Link to comment
https://forums.phpfreaks.com/topic/125368-solved-url-parameter/
Share on other sites

All i need to know is how to make a URL parameter or what it is. but hold on let me find the script

search.php

<?php require_once('Connections/Maodatabase.php'); ?>
<?php
mysql_select_db($database_Maodatabase, $Maodatabase);
$query_Recordset1 = "SELECT RegLastName FROM registrants ORDER BY RegLastName ASC";
$Recordset1 = mysql_query($query_Recordset1, $Maodatabase) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Workshop Registration</title>
<style type="text/css">
<!--
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
a:link {
color: #330066;
}
a:visited {
color: #330066;
}
a:hover {
color: #330066;
}
a:active {
color: #330066;
}
-->
</style>
</head>

<body>
<table width="700">
 <tr>
   <td><img src="banner.gif" width="700" height="92" /></td>
 </tr>
 <tr>
   <td>
</td>
 </tr>
 <tr>
   <td><center>
       <form id="form1" name="form1" method="get" action="results.php">
	<table width="265" border="1">
     <tr>
       <td width="150"><strong>Search by Last Name </strong></td>
       <td width="99"><label>
         <select name="select">
           <?php
do {  
?>
           <option value="<?php echo $row_Recordset1['RegLastName']?>"><?php echo $row_Recordset1['RegLastName']?></option>
           <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
 $rows = mysql_num_rows($Recordset1);
 if($rows > 0) {
     mysql_data_seek($Recordset1, 0);
  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
 }
?>
         </select>
       </label></td>
     </tr>
     <tr>
       <td> </td>
       <td>
         <input type="submit" name="Submit" value="Submit" />        </td>
     </tr>
   </table>
       </form>
   </center>
   <div align="center"><span class="style1"><a href="register.php">Registration</a> | <a href="view.php">View
   Registrations</a> | <a href="search.php">Edit Registrations</a> </span></div></td>
 </tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

 

results.php

<?php require_once('Connections/Maodatabase.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
 $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

 switch ($theType) {
   case "text":
     $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
     break;    
   case "long":
   case "int":
     $theValue = ($theValue != "") ? intval($theValue) : "NULL";
     break;
   case "double":
     $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
     break;
   case "date":
     $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
     break;
   case "defined":
     $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
     break;
 }
 return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
 $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
 $updateSQL = sprintf("UPDATE registrants SET Username=%s, Password=%s, RegID=%s, RegFirstName=%s, RegAddress=%s, RegPhone=%s, RegEmail=%s, RegPeriod1RM=%s, RegPeriod1=%s, RegPeriod2RM=%s, RegPeriod2=%s, RegPeriod3RM=%s, RegPeriod3=%s, RegPeriod4RM=%s, RegPeriod4=%s, RegPeriod5RM=%s, RegPeriod5=%s, RegPeriod6RM=%s, RegPeriod6=%s, RegPeriod7RM=%s, RegPeriod7=%s, RegPeriod8RM=%s, RegPeriod8=%s, RegAcademy=%s WHERE RegLastName=%s",
                      GetSQLValueString($_POST['Username'], "text"),
                      GetSQLValueString($_POST['Password'], "text"),
                      GetSQLValueString($_POST['RegID'], "int"),
                      GetSQLValueString($_POST['RegFirstName'], "text"),
                      GetSQLValueString($_POST['RegAddress'], "text"),
                      GetSQLValueString($_POST['RegPhone'], "text"),
                      GetSQLValueString($_POST['RegEmail'], "text"),
                      GetSQLValueString($_POST['RegPeriod1RM'], "text"),
                      GetSQLValueString($_POST['RegPeriod1'], "text"),
                      GetSQLValueString($_POST['RegPeriod2RM'], "text"),
                      GetSQLValueString($_POST['RegPeriod2'], "text"),
                      GetSQLValueString($_POST['RegPeriod3RM'], "text"),
                      GetSQLValueString($_POST['RegPeriod3'], "text"),
                      GetSQLValueString($_POST['RegPeriod4RM'], "text"),
                      GetSQLValueString($_POST['RegPeriod4'], "text"),
                      GetSQLValueString($_POST['RegPeriod5RM'], "text"),
                      GetSQLValueString($_POST['RegPeriod5'], "text"),
                      GetSQLValueString($_POST['RegPeriod6RM'], "text"),
                      GetSQLValueString($_POST['RegPeriod6'], "text"),
                      GetSQLValueString($_POST['RegPeriod7RM'], "text"),
                      GetSQLValueString($_POST['RegPeriod7'], "text"),
                      GetSQLValueString($_POST['RegPeriod8RM'], "text"),
                      GetSQLValueString($_POST['RegPeriod8'], "text"),
                      GetSQLValueString($_POST['RegAcademy'], "text"),
                      GetSQLValueString($_POST['RegLastName'], "text"));

 mysql_select_db($database_Maodatabase, $Maodatabase);
 $Result1 = mysql_query($updateSQL, $Maodatabase) or die(mysql_error());

 $updateGoTo = "thanksedit.php";
 if (isset($_SERVER['QUERY_STRING'])) {
   $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
   $updateGoTo .= $_SERVER['QUERY_STRING'];
 }
 header(sprintf("Location: %s", $updateGoTo));
}

$colname_Recordset1 = "-1";
if (isset($_GET['Select'])) {
 $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['Select'] : addslashes($_GET['Select']);
}
mysql_select_db($database_Maodatabase, $Maodatabase);
$query_Recordset1 = sprintf("SELECT * FROM registrants WHERE RegLastName = '%s'", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $Maodatabase) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Workshop Registration</title>
<style type="text/css">
<!--
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
a:link {
color: #330066;
}
a:visited {
color: #330066;
}
a:hover {
color: #330066;
}
a:active {
color: #330066;
}
-->
</style>
</head>

<body>
<table width="700">
 <tr>
   <td><img src="banner.gif" width="700" height="92" /></td>
 </tr>
 <tr>
   <td><form method="post" name="form1" action="<?php echo $editFormAction; ?>">
       <table align="center">

         <tr valign="baseline">
           <td nowrap align="right">FirstName:</td>
           <td><input type="text" name="RegFirstName" value="<?php echo $row_Recordset1['RegFirstName']; ?>" size="32"></td>
         </tr>
         <tr valign="baseline">
           <td nowrap align="right">LastName:</td>
           <td><input type="text" name="RegFirstName" value="<?php echo $row_Recordset1['RegLastName']; ?>" size="32"></td>
         </tr>
         <tr valign="baseline">
           <td nowrap align="right">Address:</td>
           <td><input type="text" name="RegAddress" value="<?php echo $row_Recordset1['RegAddress']; ?>" size="32"></td>
         </tr>
         <tr valign="baseline">
           <td nowrap align="right">Phone:</td>
           <td><input type="text" name="RegPhone" value="<?php echo $row_Recordset1['RegPhone']; ?>" size="32"></td>
         </tr>
         <tr valign="baseline">
           <td nowrap align="right">Email:</td>
           <td><input type="text" name="RegEmail" value="<?php echo $row_Recordset1['RegEmail']; ?>" size="32"></td>
         </tr>

         <tr valign="baseline">
           <td nowrap align="right"> </td>
           <td><input type="submit" value="Update record"></td>
         </tr>

       </table>
       <input type="hidden" name="MM_update" value="form1">
       <input type="hidden" name="RegLastName" value="<?php echo $row_Recordset1['RegLastName']; ?>">
   </form>
   </td>
 </tr>
 <tr>
   <td><div align="center"><span class="style1"><a href="register.php">Registration</a> | <a href="view.php">View
   Registrations</a> | <a href="search.php">Edit Registrations</a> </span></div></td>
 </tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

 

ignore the extra value strings

Link to comment
https://forums.phpfreaks.com/topic/125368-solved-url-parameter/#findComment-648150
Share on other sites

Well, then you would need a form on the page, or a select list or whatever you are doing....

 

<form action="processForm.php" method="post">
<input type="text" name="lastname" />
<input type="submit" value="Send" />
</form>

 

Then when they hit submit the form is sent to 'processForm.php'.

Within that script, you would:

$lname = isset($_POST['lastname']) ? $_POST['lastname'] : "";

now if the form was submitted and lastname had a value you could:

if(!empty($lname)){
  //do whatever with lname, use it for a db search and return the data for that person to edit
}

 

You don't have to send it to a different page, you could submit the form to the same page if you wanted...

 

Hope that helps a bit...

Link to comment
https://forums.phpfreaks.com/topic/125368-solved-url-parameter/#findComment-648213
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.