•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 425,892 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,029 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 641 | Replies: 5 | Solved
![]() |
•
•
Join Date: Jun 2008
Posts: 4
Reputation:
Rep Power: 0
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: 4
Reputation:
Rep Power: 0
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 8:00 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
shade out ? You mean read only ?
<input type="text" name="id" readonly>
<input type="text" name="id" readonly>
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
amd avatar backup blue gene breach browser business chips daniweb data data protection database development dos energy enterprise europe government hardware hp ibm ibm. news intel ibm it linux medicine memory messaging microsoft myspace news open source openoffice pc post to ps3 recession red hat security server spoof sun supercomputer supercomputing trends ubuntu web working x86
- memory management in wndows 2000 (Windows NT / 2000 / XP / 2003)
- Help me in username and password validation through accessing the database (ASP.NET)
- Struggling with Captcha (PHP)
- ASP.NET Registration Page (ASP.NET)
- 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



Linear Mode