| | |
Take part of URL, put into form, post to database.
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jun 2008
Posts: 6
Reputation:
Solved Threads: 0
Hi, I am very new to php and this forum so sorry if this has been asked over and over but I can't find anything when searching.
Anyway I have used some script I found on the net which has a register a new member form and a login form which then redirects to a secure page, all of this works fine. I have added an extra textfield in the register form which will pull the id from the url i.e. www.mysite/register.php?id=1 and then echo it back into the new textfield of the form. I have done this so if a new member has been refered by a member the id in the url will relate to the referer and I can then find out where the new member came from however when I submit the form I get this message - Notice: Undefined index: recomendedbyid in C:\wamp\www\mysite\register.php on line 65
Column 'recomendedbyid' cannot be null. It's as if it can't see the id that is showing in the textfield. The way I got the id into the textfield was by using
<td><?php $id = $_GET['id']; ?>
<input type="int" name="textfield" id="textfield" value="<?php echo htmlentities($id);?>" /></td>
but that is all I have done, I havn't changed anything else in the orriginal code. I hope this makes sense and any help would be great.
Anyway I have used some script I found on the net which has a register a new member form and a login form which then redirects to a secure page, all of this works fine. I have added an extra textfield in the register form which will pull the id from the url i.e. www.mysite/register.php?id=1 and then echo it back into the new textfield of the form. I have done this so if a new member has been refered by a member the id in the url will relate to the referer and I can then find out where the new member came from however when I submit the form I get this message - Notice: Undefined index: recomendedbyid in C:\wamp\www\mysite\register.php on line 65
Column 'recomendedbyid' cannot be null. It's as if it can't see the id that is showing in the textfield. The way I got the id into the textfield was by using
<td><?php $id = $_GET['id']; ?>
<input type="int" name="textfield" id="textfield" value="<?php echo htmlentities($id);?>" /></td>
but that is all I have done, I havn't changed anything else in the orriginal code. I hope this makes sense and any help would be great.
•
•
Join Date: Jun 2008
Posts: 6
Reputation:
Solved Threads: 0
Hi, thanks for your quick reply but I need the id to from the url to show in the text field so when I submit the form the id will post to the database. If it helps this is the code I'm using to submit the form and the form itself with the change advised from you.
Thanks again for the help.
php Syntax (Toggle Plain Text)
<?php require_once('modulatemedia.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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; } } // *** Redirect if username exists $MM_flag="MM_insert"; if (isset($_POST[$MM_flag])) { $MM_dupKeyRedirect="register2.php"; $loginUsername = $_POST['username']; $LoginRS__query = sprintf("SELECT username FROM members WHERE username=%s", GetSQLValueString($loginUsername, "text")); mysql_select_db($database_modulatemedia, $modulatemedia); $LoginRS=mysql_query($LoginRS__query, $modulatemedia) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); //if there is a row in the database, the username was found - can not add the requested username if($loginFoundUser){ $MM_qsChar = "?"; //append the username to the redirect page if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&"; $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername; header ("Location: $MM_dupKeyRedirect"); exit; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO members (firstname, lastname, username, password, email, recomendedbyid) VALUES (%s, %s, %s, md5(%s), %s, %s)", GetSQLValueString($_POST['firstname'], "text"), GetSQLValueString($_POST['lastname'], "text"), GetSQLValueString($_POST['username'], "text"), GetSQLValueString($_POST['password'], "text"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['recomendedbyid'], "int")); mysql_select_db($database_modulatemedia, $modulatemedia); $Result1 = mysql_query($insertSQL, $modulatemedia) or die(mysql_error()); $insertGoTo = "stores.html"; if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $insertGoTo)); } ?> <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>"> <label></label> <table width="241" border="0" align="center"> <tr> <td colspan="2"><h2 align="center" class="style4">Registration</h2> </td> </tr> <tr> <td width="79"><span class="style3"><strong> </strong> </span> <span class="style2"> </span> <div align="right" class="style3"><strong>*Username:</strong></div> </td> <td width="152"><input name="username" type="text" id="username" tabindex="1" maxlength="20" /></td> </tr> <tr> <td><span class="style3"><strong> </strong> </span> <span class="style2"> </span> <div align="right" class="style3"><strong>*Password:</strong></div> </td> <td><input name="password" type="password" id="password" tabindex="2" maxlength="20" /></td> </tr> <tr> <td><span class="style3"><strong> </strong> </span> <span class="style2"> </span> <div align="right" class="style3"><strong>*Email:</strong></div> </td> <td><input name="email" type="text" id="email" tabindex="3" maxlength="50" /></td> </tr> <tr> <td class="style3"><div align="right"><strong>*Firstname:</strong></div></td> <td><input name="firstname" type="text" id="firstname" tabindex="3" maxlength="50" /></td> </tr> <tr> <td class="style3"><div align="right"><strong>*Lastname:</strong></div></td> <td><input name="lastname" type="text" id="lastname" tabindex="3" maxlength="50" /></p></td> </tr> <tr> <td><div align="right">*Referal ID</div></td> <td><?php $id = $_GET['id']; ?> <input type="int" name="id" id="textfield"?></td> </tr> <tr> <td> </td> <td><input name="submit" type="submit" id="submit" tabindex="4" onclick="MM_validateForm('username','','R');MM_validateForm('password','','R');MM_validateForm('email','','RisEmail');return document.MM_returnValue" value="Register" /></td> </tr> <tr> <td> </td> <td><span class="style7"><a href="file:///C|/Users/Up Stairs/Desktop/login script/login.php">login</a></span></td> </tr> <tr> <td> </td> <td><span class="style7">*required fields</span></td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> </form>
Thanks again for the help.
Last edited by peter_budo; Jun 16th, 2008 at 9:00 am. Reason: Keep It Organized - please use [code] tags
![]() |
Similar Threads
- ASP.NET Registration Page (ASP.NET)
- memory management in wndows 2000 (Windows NT / 2000 / XP)
- Help me in username and password validation through accessing the database (ASP.NET)
- Struggling with Captcha (PHP)
- ugh! One Page, 2 re-loads (page request i guess) (PHP)
- ASP.Net Security 101 Part 1 (ASP.NET)
Other Threads in the PHP Forum
- Previous Thread: insert data from box
- Next Thread: storing url in variable and query update error
Views: 1822 | Replies: 5
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code computing cron curl database date delete directory display domain download dynamic echo email error file files folder form forms function functions google href htaccess html image include indentedsubcategory insert integration ip java javascript joomla jquery limit link load login loop mail menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube






