
GreenSmurf
Members-
Posts
108 -
Joined
-
Last visited
Everything posted by GreenSmurf
-
Actually I just had the idea that it should be checkboxes and each one should be passes as a search under a certain catagory. Same idea but a little more complicated. If anyone has some advice please let me know. -Brandon
-
Is there a relatively easy way to create an automated search in PHP? I was thinking of a drop down menu or even radio buttons but I wanted a couple of opinions. Basically, I want to replace a search box with something that will automatically input the string searched for but I also want it to only search certain catagories based on each option. Radio Buttons If (isset(Option A)){ $searchstring='db_col1= ABC'; } else if (isset(Option B)){ $searchstring='db_col2= BCD'; } else { $searchstring=''; } sql ="SELECT * FROM database WHERE $searchstring"; Drop Down Menu If ($_REQUEST(Option A)!=''){ $searchstring='db_col1= ABC'; } else if ($_REQUEST(Option B)!=''){ $searchstring='db_col2= BCD'; } else{ $searchstring=''; } sql ="SELECT * FROM database WHERE $searchstring"; Something like that- not too sure if those are accurate examples. I kind of just made them up. I guess I just want to know what you would consider efficient and also practical. Perhaps some examples of code to make your case would help too although definitly not necesary. Thank you. -Brandon
-
Thank you. I also found that if you use the disable property in the <textarea> it works fine as well or with the type="text" parameter readonly work well as a proterty. -Brandon
-
Excuse me but it slipped my mind. I was busy trying to fix it at the same time. The error was: SMTP server response: 503 RCPT first (#5.5.1) I found out it was because I was trying to submit a hidden value; like so, <input type="hidden" name="email" value="<? $email ?>"> If you have any suggestions on how I can submit a value without it being editable by the user that wouls be awesome. -Brandon
-
New code, new error. $myemail = $_REQUEST["myemail"]; $subject = $_REQUEST["subject"]; $email = $_REQUEST["email"]; $comments = $_REQUEST["comments"]; $to_email = explode(" ", $email); for($i = 0; $i < count($to_email); $i++){ echo $to_email[$i]."<br>"; if (isset($myemail)){ if (isset($to_email[$i])){ if (!isset($e_subject) OR !isset($message)){ echo "Subject or body of e-mail left blank."; } else { mail($to_email[$i],$subject,$comments,"From: $myemail"); echo "Mail sent to".$to_email[$i].".<br>"; } } else { echo " Recipient e-mail was left blank."; } } else { echo "Your e-mail was not entered properly."; } } Any suggestions? -Brandon
-
Seems to be having a problem getting the while loop to work. I have echo setup to show variables being passed and it seems that the line of code: echo "$my_email || $to_email[$i] || $e_subject || $message<br><br>"; Is not outputting anything. $my_email = $_REQUEST["myemail"]; $e_subject = $_REQUEST["subject"]; $email = $_REQUEST["email"]; $message = $_REQUEST["comments"]; $resultsnumber = $_REQUEST["resultsnumber"]; $to_email = explode(" ", $email); for($i = 0; $i < count($to_mail); $i++){ echo "$my_email || $to_email[$i] || $e_subject || $message<br><br>"; if (isset($myemail)){ if (isset($to_email[$i])){ if (!isset($e_subject) OR !isset($message)){ echo "Subject or body of e-mail left blank."; } else { mail($to_email[$i],$e_subject,$message,"From: $my_email"); echo "Mail sent." ; } } else { echo " Recipient e-mail was left blank."; } } else { echo "Your e-mail was not entered properly."; } } Any suggestion as to what I did wrong? -Brandon
-
It does. I will look documentation on explode() and try to incorporate it. Thank you. If I have problems I will post again. -Brandon
-
If I used $to_email= $_REQUEST['email']; and $to_email then equalled this string, "[email protected] [email protected] [email protected]" How would I extract the first email from the string then the second so on and so fourth while inside of a loop? -Brandon
-
[SOLVED] Help with using selections and emailing
GreenSmurf replied to GreenSmurf's topic in PHP Coding Help
This is what the bottom of my table looks like for my testing database. I want to be able to click the select boxes which are marker with 'id' and use their stored e-mail and names to send to another script (mail.php or something). That way all I have to do is enter the subject and message and I can mass e-mail them. I need help with gathering the information from the database based on the ticked selection boxes (hidden 'id' number) into an array. I have a button in place at the bottom but it uses a javascript to send the info over to Outlook. I want to cut Outlook out of this process. -Brandon -
[SOLVED] Help with using selections and emailing
GreenSmurf replied to GreenSmurf's topic in PHP Coding Help
Edit my previous request. Can someone help me form an e-mail script based on my code? I want to be able to select any row from the database diplayed in the table and send their first name, last name, and e-mail to a script that I can send e-mails with. I may already have a somewhat working e-mail script but it is based off a guide I found online and seems to have its own limitations. I want to be able to send the required info to the script before I get too far ahead. Thanks. -Brandon -
I have my index.php page listed here. Now the area I want to focus on is being able to select peoples and mass send an e-mail. Preferably just send a list of names and e-mail addresses to another page to interpret and allow the user to send the e-mails. I suppose that what I am looking for is an easy way to pull the information and send it through a submition button. <? include ("include/dbconnect.php"); include ("include/format.inc.php"); ?><title>Address book <? echo ($group_name != "" ? "($group_name)":""); ?></title><? include ("include/header.inc.php"); ?> <br><br> <center> <table border="0" cellspacing="2"> <form method="POST" action="<? $PHP_SELF ?>"> <tr valign=center> <td valign="top"> <input type="text" value="<? echo $searchstring; ?>" name="searchstring" title="Search for any text" size="45"/> <input type="submit" value="Search"></td> <td> </td></tr> </form> <script type="text/javascript"> function MassSelection() { for (i = 0; i < document.getElementsByName("selected[]").length; i++) { document.getElementsByName("selected[]")[i].checked = document.getElementById("MassCB").checked; } // location.href = "mailto:"+addresses; } function MailSelection() { var addresses = ""; var dst_count = 0; for (i = 0; i < document.getElementsByName("selected[]").length; i++) { if( document.getElementsByName("selected[]")[i].checked == true) { if( document.getElementsByName("selected[]")[i].accept != "") { addresses = addresses + ";" + document.getElementsByName("selected[]")[i].accept; dst_count++; } } } if(dst_count == 0) alert("No address selected."); else location.href = "mailto:"+addresses; } </script> <!-- <table width=100%><td valign=top style="border-top-width:2.5px;border-top-style:solid;border-top-color:#FFFFFF"> --> <tr><td> <? $page_name="index.php"; // If you use this code with a different page ( or file ) name then change this if(!($start > 0)) { // This variable is set to zero for the first page $start = 0; } $eu = ($start - 0); $limit = 35; // No of records to be shown per page. $this2 = $eu + $limit; $back = $eu - $limit; $next = $eu + $limit; //$grp = $_REQUEST["group"]; /*$sql="SELECT group_name FROM $table_groups ORDER BY lower(group_name) ASC"; $result_groups = mysql_query($sql); $myrow = mysql_fetch_array($result_groups);*/ /*if ($grp == '' OR $grp == NULL){ $grpDis = ''; } else { $grpDis = 'group='.$grp.'&'; //./?group=$group_name' } */ $alpha = $_REQUEST["alphabet"]; //Alpha Check if ($alpha != NULL OR $alpha != '') $alpha='alphabet='.$_REQUEST["alphabet"].'&'; //Group Check if ($group_name != ""){ $grp=ereg_replace(" ",'+',$group_name); $grpdis='group='.$grp.'&'; } //Search Check if ($searchstring != ""){ $search='searchstring='.$searchstring."&"; } if ($_REQUEST["sort"]!= ''){ $pSort = 'sort='.$_REQUEST["sort"].'&'; } if ($_REQUEST["order"]!= ''){ $pOrder = 'order='.$_REQUEST["order"].'&'; } $link = "index${page_ext_qry}".$search.$stDis."alphabet"; $link2 = "index${page_ext_qry}".$alpha.$search.$stDis; //echo $start."||".$_REQUEST["start"]."<br><br>"; echo "<a style='font-size:85%' href='$link=a'>A</a> | <a style='font-size:85%' href='$link=b'>B</a> | <a style='font-size:85%' href='$link=c'>C</a> | <a style='font-size:85%' href='$link=d'>D</a> | <a style='font-size:85%' href='$link=e'>E</a> | <a style='font-size:85%' href='$link=f'>F</a> | <a style='font-size:85%' href='$link=g'>G</a> | <a style='font-size:85%' href='$link=h'>H</a> | <a style='font-size:85%' href='$link=i'>I</a> | <a style='font-size:85%' href='$link=j'>J</a> | <a style='font-size:85%' href='$link=k'>K</a> | <a style='font-size:85%' href='$link=l'>L</a> | <a style='font-size:85%' href='$link=m'>M</a> | <a style='font-size:85%' href='$link=n'>N</a> | <a style='font-size:85%' href='$link=o'>O</a> | <a style='font-size:85%' href='$link=p'>P</a> | <a style='font-size:85%' href='$link=q'>Q</a> | <a style='font-size:85%' href='$link=r'>R</a> | <a style='font-size:85%' href='$link=s'>S</a> | <a style='font-size:85%' href='$link=t'>T</a> | <a style='font-size:85%' href='$link=u'>U</a> | <a style='font-size:85%' href='$link=v'>V</a> | <a style='font-size:85%' href='$link=w'>W</a> | <a style='font-size:85%' href='$link=x'>X</a> | <a style='font-size:85%' href='$link=y'>Y</a> | <a style='font-size:85%' href='$link=z'>Z</a> | <a style='font-size:85%' href='".($group == '' || $group == '[none]' || $fixgroup ? "$link=''" : '?group='.$group)."'>All</a>"; ?> </td> </table> </center> <br> <hr> <? //Shorten String Function Just like it sounds function ShortenText($text) { // Change to the number of characters you want to display $chars = 20; $text = $text." "; $text = substr($text,0,$chars); $text = substr($text,0,strrpos($text,' ')); $text = $text."..."; return $text; } //End Function //Phone Function function phone_number($sPhone) { $sPhone = ereg_replace("[^0-9]",'',$sPhone); if(strlen($sPhone) != 10) return(False); $sArea = substr($sPhone,0,3); $sPrefix = substr($sPhone,3,3); $sNumber = substr($sPhone,6,4); $sPhone = "(".$sArea.")".$sPrefix."-".$sNumber; return($sPhone); } //End Function // //SORT!!! // $rSort = $_REQUEST["sort"]; if ($searchstring!="" AND $rSort==""){ $rsort = 'lastname, firstname, boss, lastname2, firstname2, clientID'; } $rOrder = $_REQUEST["order"]; if ($rOrder == '' OR $rOrder=='ASC'){ $rOrder = 'DESC'; } else { $rOrder = 'ASC'; } if ($rOrder!='' AND $rSort!='') { $sort = 'ORDER BY '.$rSort.' '.$rOrder; } else { $sort = 'ORDER BY lastname, firstname, boss'; } //End Sort! // if ($searchstring AND $alphabet) { $sql="SELECT * FROM $base_from_where AND LEFT(lastname,1) = '$alphabet' AND (lastname LIKE '%$searchstring%' OR firstname LIKE '%$searchstring%' OR lastname2 LIKE '%$searchstring%' OR firstname2 LIKE '%$searchstring%' OR address LIKE '%$searchstring%' OR boss LIKE '%$searchstring%' OR clientID LIKE '%$searchstring%' OR accnt LIKE '%$searchstring%' OR salesrep LIKE '%$searchstring%' OR email LIKE '%$searchstring%') ".$sort." LIMIT $eu, $limit;"; $query2="SELECT * FROM $base_from_where AND LEFT(lastname,1) = '$alphabet' AND (lastname LIKE '%$searchstring%' OR firstname LIKE '%$searchstring%' OR lastname2 LIKE '%$searchstring%' OR firstname2 LIKE '%$searchstring%' OR address LIKE '%$searchstring%' OR boss LIKE '%$searchstring%' OR clientID LIKE '%$searchstring%' OR accnt LIKE '%$searchstring%' OR salesrep LIKE '%$searchstring%' OR email LIKE '%$searchstring%') ".$sort.";"; $result2=mysql_query($query2); $nume=mysql_num_rows($result2); } else if ($searchstring) { $sql="SELECT * FROM $base_from_where AND (lastname LIKE '%$searchstring%' OR firstname LIKE '%$searchstring%' OR lastname2 LIKE '%$searchstring%' OR firstname2 LIKE '%$searchstring%' OR address LIKE '%$searchstring%' OR boss LIKE '%$searchstring%' OR clientID LIKE '%$searchstring%' OR accnt LIKE '%$searchstring%' OR salesrep LIKE '%$searchstring%' OR email LIKE '%$searchstring%') ".$sort." LIMIT $eu, $limit;"; $query2="SELECT * FROM $base_from_where AND (lastname LIKE '%$searchstring%' OR firstname LIKE '%$searchstring%' OR lastname2 LIKE '%$searchstring%' OR firstname2 LIKE '%$searchstring%' OR address LIKE '%$searchstring%' OR boss LIKE '%$searchstring%' OR clientID LIKE '%$searchstring%' OR accnt LIKE '%$searchstring%' OR salesrep LIKE '%$searchstring%' OR email LIKE '%$searchstring%') ".$sort.";"; $result2=mysql_query($query2); $nume=mysql_num_rows($result2); } else if ($alphabet) { $sql = "SELECT * FROM $base_from_where AND LEFT(lastname,1) = '$alphabet' ".$sort." LIMIT $eu, $limit;"; $query2="SELECT * FROM $base_from_where AND LEFT(lastname,1) = '$alphabet' ".$sort.";"; $result2=mysql_query($query2); $nume=mysql_num_rows($result2); } else { $sql="SELECT * FROM $base_from_where ".$sort." LIMIT $eu, $limit;"; $query2="SELECT * FROM $base_from_where ".$sort.";"; $result2=mysql_query($query2); $nume=mysql_num_rows($result2); } $result = mysql_query($sql); $resultsnumber = mysql_numrows($result); echo "<TABLE BORDER=0 width=100%>"; echo "<td><strong>Number of results: $nume</td>"; if(isset($table_groups) and $table_groups != "" and !$is_fix_group) { ?> <td align=right> <form> <select name="group" onChange="this.parentNode.submit()"> <? if($group_name != "") { echo "<option>$group_name</option>\n"; } ?> <option value="">[all]</option> <option value="[none]">[none]</option> <? $sql="SELECT group_name FROM $table_groups ORDER BY lower(group_name) ASC"; $result_groups = mysql_query($sql); $result_gropup_snumber = mysql_numrows($result_groups); while ($myrow = mysql_fetch_array($result_groups)) { echo "<option>".$myrow["group_name"]."</option>\n"; } ?> </select> </form> </td></tr> </table> <? } ?> <form name=MainForm method="POST" action="group<? echo $page_ext; ?>"> <input type="hidden" name="group" value="<? echo $group; ?>"> <table border=0 cellpadding="6" align="center"> <col width=1*> <col width=2*> <col width=3*> <col width=4*> <col width=1> <col width=150> <col width=84> <col width=16> <col width=16> <col width=16> <col width=16> <col width=16> <col width=6*> <tr padding="0" align="center"> <td> </td> <td><u><a href=<?php echo $link2 ?>sort=clientID&order=<?php echo $rOrder ?>>Client ID</a></u></td> <td><u><a href=<?php echo $link2 ?>sort=lastname&order=<?php echo $rOrder ?>>Lastname</a></u></td> <td><u><a href=<?php echo $link2 ?>sort=firstname&order=<?php echo $rOrder ?>>Firstname</a></u></td> <td><u><a href=<?php echo $link2 ?>sort=boss&order=<?php echo $rOrder ?>>Company</a></u></td> <td><u><a href=<?php echo $link2 ?>sort=email&order=<?php echo $rOrder ?>>E-mail</a></u></td> <td><u>Phone #</u></td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td><u><a href=<?php echo $link2 ?>sort=accnt&order=<?php echo $rOrder ?>>Accountant</a></u></td> <td><u>Activity</u></td> </tr> <? $alternate = "2"; include ("guess.inc"); while ($myrow = mysql_fetch_array($result)) { $clientID = $myrow["clientID"]; $firstname = $myrow["firstname"]; $id = $myrow["id"]; $lastname = $myrow["lastname"]; $boss = $myrow["boss"]; $email = ($myrow["email"] != "" ? $myrow["email"] : ($myrow["email2"] != "" ? $myrow["email2"] : "")); $email2 = $myrow["email2"]; $home = $myrow["home"]; $mobile = $myrow["mobile"]; $work = $myrow["work"]; $accnt = $myrow["accnt"]; $notes = $myrow["notes"]; // Phone order home->mobile->work $phone = ($myrow["home"] != "" ? $myrow["home"] : ($myrow["mobile"] != "" ? $myrow["mobile"] : $myrow["work"])); /*$phone = str_replace("'", "", str_replace('/', "", str_replace(" ", "", str_replace(".", "", $phone))));*/ $phone = phone_number($phone); if ($alternate == "1") { $color = "#ffffff"; $alternate = "2"; } else { $color = "#efefef"; $alternate = "1"; } echo "<TR bgcolor=$color>"; echo "<TD><input type=checkbox id=".$id." name='selected[]' value='$id' title='Select ($firstname $lastname)' alt='Select ($firstname $lastname)' accept=".$myrow['email'].";".$myrow['email2']."></td>"; echo "<td>$clientID</td>"; echo "<TD>$lastname</td>"; echo "<td>$firstname</td>"; echo "<td>".ShortenText($boss)."</td>"; echo "<td><a href='mailto:$email'>$email</a></td>"; echo "<td align=right>$phone</td>"; echo "<td><a href='view${page_ext_qry}id=$id'><img border=0 src=icons/status_online.png width=16 height=16 title='Details' alt='Details'/></a></td>"; if(! $read_only) echo "<td><a href='edit${page_ext_qry}id=$id'><img border=0 src=icons/pencil.png width=16 height=16 title='Edit' alt='Edit'/></a></td>"; echo "<td><font size=-2><a href='vcard${page_ext_qry}id=$id'><img border=0 src=icons/vcard.png width=16 height=16 title='vCard' alt='vCard'/></a></font></td>"; if( substr($phone, 0, 1) == "0" || substr($phone, 0, 3) == "+41") { $country = "Switzerland"; } else $country = ""; if($map_guess) { if($myrow["address"] != "") echo "<td><font size=-2><a href='http://maps.google.com/maps?q=".urlencode(trim(str_replace("\r\n", ", ", $myrow["address"]))." ".trim($myrow["city"]).", ".trim($myrow["state"])." ".trim($myrow["zip"]).", $country")."&t=h' target='_blank'> <img border=0 src=icons/car.png width=16 height=16 title='Google Maps' alt='vCard'/></a></font></td>"; else echo "<td/>"; } $homepage = guessHomepage($email, $email2); if(strlen($homepage) > 0) { echo "<td><font size=-2><a href='http://$homepage' target='_blank'><img border=0 src=icons/house.png width=16 height=16 title='Guessed Homepage ($homepage)' alt='Guessed Homepage ($homepage)'/></a></font></td>"; } else echo "<td/>"; echo "<td><a href=\"javascript:popImage('$accnt.jpg','$accnt')\">$accnt</a></td>"; echo "<td>".ShortenText($notes)."</td>"; echo "</TR>\n"; } echo "<tr height=2/>"; echo "<TR >"; echo "<TD><input type=checkbox id=MassCB onclick=\"MassSelection()\"></td><td><em><strong>Select all</strong></em></TD>"; echo "</TR>\n"; echo "<tr height=9/>"; echo "</TR></TABLE>"; echo "<TABLE width=100%><TR>"; echo "<td><input type=button value=\"Send e-Mail\" onclick=\"MailSelection()\"/></td>"; if(isset($table_groups) and $table_groups != "" and !$is_fix_group) { // -- Remove from group -- if($group_name != "" and $group_name != "[none]") { echo "<td align=center><input type=submit name=remove value='Remove from \"$group_name\"'/></td>"; } else echo "<td align=center/>"; // -- Add to a group -- echo "<td align=right><input type=submit name=add value='Add to group'/>-"; echo "<select name=to_group>"; $sql="SELECT group_name FROM $table_groups ORDER BY lower(group_name) ASC"; $result = mysql_query($sql); $resultsnumber = mysql_numrows($result); while ($myrow = mysql_fetch_array($result)) { echo "<option>".$myrow["group_name"]."</option>\n"; } echo "</select>"; } echo "</TR></form>"; // Show group footer if($group_name != "" and $group_myrow['group_footer'] != "") { echo "<tr><td colspan=3><hr>"; echo $group_myrow['group_footer']; echo "<hr></td></tr>"; } echo "</TABLE>"; //Start (Pagination) Check $pageNum = $_REQUEST["start"]; // if ($start != NULL OR $start != ''){ if ($start > $nume){ while($start>$nume) { $start=$start-$limit; } } $stDis='start='.$eu.'&'; } $link3 = "index${page_ext_qry}".$alpha.$search.$pSort.$pOrder; //Prev & Next Buttons if ( $limit < $nume) { echo "<table align = 'center' width='25%'><tr><td align='left' width='15%'>"; if($back >=0) { print "<a href=".$link3."start=".$back."><font face='Verdana' size='2'>PREV</font></a>"; } echo "</td><td align=center width='70%'>"; $i=0; $l=1; for($i=0;$i < $nume;$i=$i+$limit){ if($i <> $eu){ echo " <a href=".$link3."start=".$i."><font face='Verdana' size='2'>$l</font></a> "; } else { echo "<font face='Verdana' size='4' color=red>$l</font>";} /// Current page is not displayed as link and given font color red $l=$l+1;} echo "</td><td align='right' width='15%'>"; if($this2 < $nume) { print "<a href=".$link3."start=".$next."><font face='Verdana' size='2'>NEXT</font></a>";} echo "</td></tr></table>"; }//End Prev & Next buttons include("include/footer.inc.php"); ?> Any idea on how to make this functional? I currently have it setup to send through Outlook but would much rather use a script than Outlook. Thanks in advanced. -Brandon
-
Is there a more secure way of creating the links in this sort? I would much rather the ?sort=... did not display in the URL. <tr padding="0" align="center"> <td> </td> <td><u><a href=index.php?sort=clientID&order=<?php echo $rOrder ?>>Client ID</a></u></td> <td><u><a href=index.php?sort=lastname&order=<?php echo $rOrder ?>>Lastname</a></u></td> <td><u><a href=index.php?sort=firstname&order=<?php echo $rOrder ?>>Firstname</a></u></td> <td><u><a href=index.php?sort=boss&order=<?php echo $rOrder ?>>Company</a></u></td> <td><u><a href=index.php?sort=email&order=<?php echo $rOrder ?>>E-mail</a></u></td> <td><u>Phone #</u></td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td><u><a href=index.php?sort=clientID&order=<?php echo $rOrder ?>>Accountant</a></u></td> <td><u>Activity</u></td> </tr> Thank you. -Brandon
-
I will get an example up soon. Sorry, I had to get some other stuff done with the DB first. -Brandon
-
$sql = "UPDATE $table SET newnotes='".sql_safe($newnotes)."', today=CURDATE() WHERE id=$id"; $result = mysql_query($sql); The error was on this line of code. It was a SQL error not PHP. Code should have been. [code]$sql = "UPDATE $table SET newnotes=".sql_safe($newnotes).", today=CURDATE() WHERE id=$id"; $result = mysql_query($sql); Because the function sql_safe adds in '' automatically to every string. -Brandon[/code]
-
Ok, the ""s did not quite fix the problem like I had thought. They still write but they give unintended output. When a new note is made the query should be sent to SQL and today will get its value from CURDATE() eg. 2008-5-28 and newnotes are the new notes input by the user obviously. Status is grabbed from a drop down menu and input automatically by the script. The CONCAT portion of the code is intended to create a list of notes in a format similar to this: if($resultsnumber > 0) { if($newnotes != NULL AND $firstname!=NULL AND $lastname!=NULL) { $sql = "UPDATE $table SET newnotes='".sql_safe($newnotes)."', today=CURDATE() WHERE id=$id"; $result = mysql_query($sql); echo $sql."<br><br>"; $sql = "UPDATE $table SET firstname=".sql_safe($firstname).",lastname=".sql_safe($lastname).", firstname2=".sql_safe($firstname2).",lastname2=".sql_safe($lastname).",clientID=".sql_safe($clientID).", boss=".sql_safe($boss).",address=".sql_safe($address).",home=".sql_safe($home).",mobile=".sql_safe($home).", work=".sql_safe($work).",email=".sql_safe($email).",email2=".sql_safe($email2).",bday=".sql_safe($bday).", bmonth=".sql_safe($bmonth).",byear=".sql_safe($byear).",address2=".sql_safe($address2).",phone2=".sql_safe($phone2).", accnt=".sql_safe($accnt).",fax=".sql_safe($fax).",ext=".sql_safe($ext).", notes=CONCAT(today,' - ',".sql_safe($status).",' - ',newnotes,CHAR(13),notes),status=".sql_safe($status).", status2=".sql_safe($status2).",status3=".sql_safe($status3).",status4=".sql_safe($status4).", personal=".sql_safe($personal).",business=".sql_safe($business).",payroll=".sql_safe($payroll).", retainer=".sql_safe($retainer).",qb=".sql_safe($qb).",comment=".sql_safe($comment)." WHERE id=$id"; Any ideas? I am unsure if it is the PHP or the mySQL that is incorrect all I know is the mySQL works perfectly if I type it in manually to Query with assigned values and it was working before I tried to use sql_safe() sql_safe() Code: //Funtion function sql_safe($value,$allow_wildcards = false, $detect_numeric = true) { // Taken from the PHP site and modified for wildcards and automatic formatting for numbers/strings. // Reverse magic_quotes_gpc/magic_quotes_sybase effects on those vars if ON. if (get_magic_quotes_gpc()) { if(ini_get('magic_quotes_sybase')) { $value = str_replace("''", "'", $value); } else { $value = stripslashes($value); } } //Escape wildcards for SQL injection protection on LIKE, GRANT, and REVOKE commands. if (!$allow_wildcards) { $value = str_replace('%','\%',$value); $value = str_replace('_','\_',$value); } // Quote if $value is a string and detection enabled. if ($detect_numeric) { if (!is_numeric($value)) { return "'" . mysql_real_escape_string($value) . "'"; } } return mysql_real_escape_string($value); } //End Function I think the problem may be here. If so, I hope to get the topic moved to the SQL help forums. -Brandon
-
Could you please explain why the . was not needed with the " in the line of code? -Brandon
-
I have the it set to output $sql but before the page loads I get: Slightly different code: $sql = "UPDATE $table SET firstname=".sql_safe($firstname).",lastname=".sql_safe($lastname).", firstname2=".sql_safe($firstname2).",lastname2=".sql_safe($lastname).",clientID=".sql_safe($clientID).", boss=".sql_safe($boss).",address=".sql_safe($address).",home=".sql_safe($home).",mobile=".sql_safe($home).", work=".sql_safe($work).",email=".sql_safe($email).",email2=".sql_safe($email2).",bday=".sql_safe($bday).", bmonth=".sql_safe($bmonth).",byear=".sql_safe($byear).",address2=".sql_safe($address2).",phone2=".sql_safe($phone2).", accnt=".sql_safe($accnt).",fax=".sql_safe($fax).",ext=".sql_safe($ext).", notes=".sql_safe(."CONCAT(today,' - ','".sql_safe($status)."',' - ',newnotes,CHAR(13),notes)".).",status=".sql_safe($status).", status2=".sql_safe($status2).",status3=".sql_safe($status3).",status4=".sql_safe($status4).", personal=".sql_safe($personal).",business=".sql_safe($business).",payroll=".sql_safe($payroll).", retainer=".sql_safe($retainer).",qb=".sql_safe($qb).",comment=".sql_safe($comment)." WHERE id=$id"; -Brandon
-
Can someone help me? I seem to have stumped myself (not very hard to do). $sql = "UPDATE $table SET firstname=".sql_safe($firstname).",lastname=".sql_safe($lastname).", firstname2=".sql_safe($firstname2).",lastname2=".sql_safe($lastname).",clientID=".sql_safe($clientID).", boss=".sql_safe($boss).",address=".sql_safe($address).",home=".sql_safe($home).",mobile=".sql_safe($home).", work=".sql_safe($work).",email=".sql_safe($email).",email2=".sql_safe($email2).",bday=".sql_safe($bday).", bmonth=".sql_safe($bmonth).",byear=".sql_safe($byear).",address2=".sql_safe($address2).",phone2=".sql_safe($phone2).", accnt=".sql_safe($accnt).",fax=".sql_safe($fax).",ext=".sql_safe($ext).", notes=".sql_safe(."CONCAT(today,' - ','".sql_safe($status)."',' - ',newnotes,CHAR(13),notes)".).",status=".sql_safe($status).", status2=".sql_safe($status2).",status3=".sql_safe($status3).",status4=".sql_safe($status4).", personal=".sql_safe($personal).",business=".sql_safe($business).",payroll=".sql_safe($payroll).", retainer=".sql_safe($retainer).",qb=".sql_safe($qb).",comment=".sql_safe($comment)." WHERE id=$id"; ERROR on this line: notes=".sql_safe(."CONCAT(today,' - ','".sql_safe($status)."',' - ',newnotes,CHAR(13),notes)".).",status=".sql_safe($status).", Thanks. -Brandon
-
Well, there is over 1200 people listed in the address book. So, I would like it to skip peope that are listed only once and I would like groups of business and persons because some people are associated with multiple businesses or some businesses are associated with muliple peoples. I would also like it to check if the group already exsists and add the person/business without creating a new one necessarily. -Brandon
-
Not really I haven't quite started but I would like it to function like this: [bob] [smith] [Crayola] [John] [Doe] [bubbleGum] [bob] [smith] [bubbleGum] Then the query should find all instances of Bob Smith and create a group named Bob Smith and associate the row of data in the db with the group name. Also, it should find the business name BubbleGum and create a group named BubbleGum and associate the row of data in the db with the group name. So I am thinking that nameID and businessID would both be necessary to track said groups. -Brandon
-
I would like to know how to create an intuitive grouping list in mysql Example- if ((lastname=same_lastname and firstname=last_firstname) or businessname=same_businessname) { create group based off of business/lastname, firstname } Could anyone give me an idea where to start? -Brandon
-
[SOLVED] One day it work the next nothing!
GreenSmurf replied to GreenSmurf's topic in PHP Coding Help
Decided to post the solution and code. Turns out the db had an extra var field in it and I needed to pass the SELECT sql code with compensation for it. Here is the new and much more complicated code: <?php include ("include/dbconnect.php"); include ("include/format.inc.php"); include ("include/header.inc.php"); php?> <h1>Edit / add address book entry</h1> <?php if($submit) { if(! $read_only) { $sql = "INSERT INTO $table (firstname, lastname, firstname2, lastname2, clientID, boss, address, home, mobile, work, email, email2, bday, bmonth, byear, address2, phone2, mobile2, work2, ext2, accnt, fax, ext, notes, status, status2, status3, status4, personal, business, payroll, retainer, qb, comment) VALUES ('$firstname','$lastname','$firstname2','$lastname2', '$clientID', '$boss', '$address','$home','$mobile','$work','$email','$email2','$bday','$bmonth','$byear','$address2','$phone2', '$mobile2', '$work2', '$ext2','$accnt','$fax','$ext', '$notes', '$status', '$status2', '$status3', '$status4', '$personal', '$business', '$payroll', '$retainer', '$qb', '$comment')"; $result = mysql_query($sql); echo $sql; echo "<br><br>"; $sql = "INSERT INTO address_in_groups SELECT LAST_INSERT_ID() id, group_id FROM group_list WHERE group_name = '".$group_name."'"; $result = mysql_query($sql); echo "<br><br>Information entered into address book,\n"; echo "<br><a href='edit$page_ext'>add next</a> or return to "; echo "<a href='index$page_ext'>home page</a>.<br>"; } else echo "<br><br>Editing is disabled.\n"; } else if($update) { if(! $read_only) { $sql="SELECT * FROM $base_from_where AND $table.id=$id"; $result = mysql_query($sql); $resultsnumber = mysql_numrows($result); if($resultsnumber > 0) { if($newnotes != NULL) { $sql = "UPDATE $table SET newnotes = '$newnotes', today = CURDATE() WHERE id=$id"; $result = mysql_query($sql); $sql = "UPDATE $table SET firstname='$firstname',lastname='$lastname', firstname2 = '$firstname2', lastname2 = '$lastname2', clientID='$clientID', boss='$boss',address='$address',home='$home',mobile='$mobile',work='$work',email='$email',email2='$email2',bday='$bday',bmonth='$bmonth',byear='$byear',address2 = '$address2', phone2 = '$phone2', accnt = '$accnt', fax = '$fax', ext = '$ext', notes = CONCAT(today,' - ',status,' - ',newnotes,CHAR(13),notes), status ='$status', status2 ='$status2', status3 ='$status3', status4 ='$status4', personal = '$personal', business = '$business', payroll = '$payroll', retainer = '$retainer', qb = '$qb', comment = '$comment' WHERE id=$id"; $result = mysql_query($sql); // header("Location: view?id=$id"); echo "<br>Address book updated.\n"; echo "<br><a href='index$page_ext'>home page</a>"; } else { $sql = "UPDATE $table SET firstname='$firstname',lastname='$lastname', firstname2 = '$firstname2', lastname2 = '$lastname2', clientID='$clientID', boss='$boss',address='$address',home='$home',mobile='$mobile',work='$work',email='$email',email2='$email2',bday='$bday',bmonth='$bmonth',byear='$byear',address2 = '$address2', phone2 = '$phone2', accnt = '$accnt', fax = '$fax', ext = '$ext', status ='$status', status2 ='$status2', status3 ='$status3', status4 ='$status4', personal = '$personal', business = '$business', payroll = '$payroll', retainer = '$retainer', qb = '$qb', comment = '$comment' WHERE id=$id"; $result = mysql_query($sql); echo $sql; echo "<br><br>"; // header("Location: view?id=$id"); echo "<br>Address book updated.\n"; echo "<br><a href='index$page_ext'>home page</a>"; } } else { echo "<br>Invalid ID.\n"; echo "<br><a href='index$page_ext'>home page</a>"; } } else echo "<br><br>Editing is disabled.\n"; } else if($id) { if(! $read_only) { $result = mysql_query("SELECT * FROM $base_from_where AND $table.id=$id",$db); $myrow = mysql_fetch_array($result); ?> <form method="post" action="edit<? echo $page_ext; ?>"> <table width="380" border="0" cellspacing="1" cellpadding="1"> <tr> <td> <input type="hidden" name="id" value="<?php echo $myrow["id"]?>"> Firstname: </td> <td> <input type="Text" name="firstname" size="35" value="<?php echo $myrow["firstname"]?>"> </td> <td>Client ID: </td> <td> <input type="Text" name="clientID" size="12" value="<?php echo $myrow["clientID"]?>"> </td> </tr> <tr> <td>Lastname: </td> <td> <input type="Text" name="lastname" size="35" value="<?php echo $myrow["lastname"]?>"> </td> <td>Business: </td> <td> <input type="Text" name="boss" size="35" value="<?php echo $myrow["boss"]?>"> </td> </tr> <tr> <td><b><u>Attention</b></u></td> <td colspan=3> <input type="Text" name="comment" size="46" value="<?php echo $myrow["comment"]?>"> </td> </tr> <tr> <td>Address: </td> <td> <textarea name="address" rows="5" cols="35"><?php echo $myrow["address"]?></textarea> </td> </tr> </table> <table> <tr> <td colspan=3><b>Telephone: </b></td> </tr> <tr> <td>Home:</td> <td> <input type="Text" name="home" value="<?php echo $myrow["home"]?>"> </td> <td>Mobile:</td> <td> <input type="Text" name="mobile" value="<?php echo $myrow["mobile"]?>"> </td> </tr> <tr> <td>Work: </td> <td> <input type="Text" name="work" value="<?php echo $myrow["work"]?>"> </td> <td>Ext:</td> <td><input type="Text" name="ext" size="6" value="<?php echo $myrow["ext"]?>"></td> </tr> <tr> <td>Fax:</td> <td><input type="Text" name="fax" value="<?php echo $myrow["fax"]?>"></td> <td> </td> <td> </td> </tr> <tr> <td>Email:</td> <td> <input type="Text" name="email" size="35" value="<?php echo $myrow["email"]?>"> </td> </tr> <tr> <td>Birthday:</td> <td> <select name="bday"> <option value="<?php echo $myrow["bday"]?>" selected><?php echo ($myrow["bday"] == 0?"-":$myrow["bday"]) ?></option> <option value="0">-</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="bmonth"> <option value="<?php echo $myrow["bmonth"] ?>" selected><?php echo $myrow["bmonth"]?></option> <option value="-">-</option> <option value="January">January</option> <option value="February">February</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <input type="text" name="byear" size="4" maxlength="4" value="<?php echo $myrow["byear"]?>"> </td> </tr> </table> <table> <tr> <td> </td> <td> </td> </tr> <tr> <td colspan=3><b>Secondary: </b></td> </tr> <tr> <td> <input type="hidden" name="id" value="<?php echo $myrow["id"]?>"> Firstname: </td> <td> <input type="Text" name="firstname2" size="35" value="<?php echo $myrow["firstname2"]?>"> </td> </tr> <tr> <td>Lastname:</td> <td> <input type="Text" name="lastname2" size="35" value="<?php echo $myrow["lastname2"]?>"> </td> </tr> <tr> <td>Address: </td> <td colspan=3> <textarea name="address2" rows="5" cols="35"></textarea> </td> </tr> <tr> <td>Home:</td> <td> <input type="Text" name="home2" value="<?php echo $myrow["home2"]?>"> </td> <td>Mobile:</td> <td> <input type="Text" name="mobile2" value="<?php echo $myrow["mobile2"]?>"> </td> </tr> <tr> <td>Work: </td> <td> <input type="Text" name="work2" value="<?php echo $myrow["work2"]?>"> </td> <td>Ext:</td> <td><input type="Text" name="ext2" size="6" value="<?php echo $myrow["ext2"]?>"></td> </tr> <tr> <td>Email:</td> <td> <input type="Text" name="email2" size="35" value="<?php echo $myrow["email2"]?>"> </td> </tr> </table> <table> <tr> <td colspan=4><b><br><br>Account Info</b></td> </tr> <tr> <td>Accountant: </td> <td> <input type="Text" name="accnt" size="35" value="<?php echo $myrow["accnt"]?>"> </td> <td>QB Password:</td> <td> <input type="text" name="qb" size="10" value="<?php echo $myrow["qb"]?>"> </td> </tr> <tr> <td> </td> <td><b>Services</b></td> <td colspan=2> </td> </tr> <tr> <td> </td> <td> <input type="checkbox" name="personal" value="checked" <?php echo $myrow["personal"] ?>>Personal </td> <td>Status</td> <td> <select name="status"> <option value="<?php echo $myrow["status"] ?>" selected><?php echo $myrow["status"]?></option> <option value="Completed">Completed</option> <option value="In Review">In Review</option> <option value="In Process">In Process</option> <option value="Sent to GKM">Sent to GKM</option> <option value="Awaiting Source Docs">Awaiting Source Docs</option> <option value="On Hold/Past Due">On Hold/Past Due</option> <option value="Cancelled">Cancelled</option> </select> </td> </tr> <tr> <td> </td> <td> <input type="checkbox" name="business" value="checked" <?php echo $myrow["business"]?>>Business </td> <td>Status</td> <td> <select name="status2"> <option value="<?php echo $myrow["status2"] ?>" selected><?php echo $myrow["status2"]?></option> <option value="Completed">Completed</option> <option value="In Review">In Review</option> <option value="In Process">In Process</option> <option value="Sent to GKM">Sent to GKM</option> <option value="Awaiting Source Docs">Awaiting Source Docs</option> <option value="On Hold/Past Due">On Hold/Past Due</option> <option value="Cancelled">Cancelled</option> </select> </td> </tr> <tr> <td> </td> <td> <input type="checkbox" name="payroll" value="checked" <?php echo $myrow["payroll"] ?>>Payroll </td> <td>Status</td> <td> <select name="status3"> <option value="<?php echo $myrow["status3"] ?>" selected><?php echo $myrow["status3"]?></option> <option value="Completed">Completed</option> <option value="In Review">In Review</option> <option value="In Process">In Process</option> <option value="Sent to GKM">Sent to GKM</option> <option value="Awaiting Source Docs">Awaiting Source Docs</option> <option value="On Hold/Past Due">On Hold/Past Due</option> <option value="Cancelled">Cancelled</option> </select> </td> </tr> <tr> <td> </td> <td> <input type="checkbox" name="retainer" value="checked" <?php echo $myrow["retainer"] ?>>Retainer </td> <td>Status</td> <td> <select name="status4"> <option value="<?php echo $myrow["status4"] ?>" selected><?php echo $myrow["status4"]?></option> <option value="Completed">Completed</option> <option value="In Review">In Review</option> <option value="In Process">In Process</option> <option value="Sent to GKM">Sent to GKM</option> <option value="Awaiting Source Docs">Awaiting Source Docs</option> <option value="On Hold/Past Due">On Hold/Past Due</option> <option value="Cancelled">Cancelled</option> </select> </td> </tr> <tr> <td>History: </td> <td colspan=3> <textarea name="notesdisplay" rows="5" cols="47"><?php echo $myrow["notes"]?></textarea> </td> </tr> <tr> <td>Notes: </td> <td colspan=3> <textarea name="newnotes" rows="5" cols="47"></textarea> </td> </tr> </table> <br> <input type="Submit" name="update" value="Update information"> </form> <br> <form method="get" action="delete<?php echo $page_ext; ?>"> <input type="hidden" name="id" value="<?php echo $myrow["id"]?>"> <input type="Submit" name="update" value="Delete information"> </form> <?php } else echo "<br><br>Editing is disabled.\n"; } else { if(! $read_only) { ?> <form method="post" action="edit<?php echo $page_ext; ?>"> <table width="380" border="0" cellspacing="1" cellpadding="1"> <tr> <td> <input type="hidden" name="id" value="<?php echo $myrow["id"]?>"> Firstname: </td> <td> <input type="Text" name="firstname" size="35"> </td> <td>Client ID: </td> <td> <input type="Text" name="clientID" size="12" value="<?php echo $myrow["clientID"]?>"> </td> </tr> <tr> <td>Lastname: </td> <td> <input type="Text" name="lastname" size="35"> </td> <td>Business: </td> <td> <input type="Text" name="boss" size="35" value="<?php echo $myrow["boss"]?>"> </td> </tr> <tr> <td><b><u>Attention</b></u></td> <td colspan=3> <input type="Text" name="comment" size="46"> </td> </tr> <tr> <td>Address: </td> <td> <textarea name="address" rows="5" cols="35"></textarea> </td> </tr> </table> <table> <tr> <td colspan=3><b>Telephone: </b></td> </tr> <tr> <td>Home:</td> <td> <input type="Text" name="home"> </td> <td>Mobile:</td> <td> <input type="Text" name="mobile"> </td> </tr> <tr> <td>Work: </td> <td> <input type="Text" name="work"> </td> <td>Ext:</td> <td> <input type="Text" name="ext" size="6"> </td> </tr> <tr> <td>Fax:</td> <td> <input type="Text" name="fax"> </td> <td> </td> <td> </td> </tr> <tr> <td>Email: </td> <td> <input type="Text" name="email" size="35"> </td> </tr> </table> <table> <tr> <td>Birthday:</td> <td> <select name="bday"> <option value="0" selected>-</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="bmonth"> <option value="-" selected>-</option> <option value="January">January</option> <option value="February">February</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <input type="Text" name="byear" size="4" maxlength="4"> </td> </tr> </table> <table> <tr> <td> </td> <td> </td> </tr> <tr> <td colspan=3><b>Secondary:</b></td> </tr> <tr> <td>Firstname: </td> <td> <input type="Text" name="firstname2" size="35"> </td> </tr> <tr> <td>Lastname: </td> <td> <input type="Text" name="lastname2" size="35"> </td> </tr> <tr> <td>Address: </td> <td colspan=3> <textarea name="address2" rows="5" cols="35"></textarea> </td> </tr> <tr> <td>Home:</td> <td> <input type="Text" name="home2"> </td> <td>Mobile:</td> <td> <input type="Text" name="mobile2"> </td> </tr> <tr> <td>Work: </td> <td> <input type="Text" name="work2"> </td> <td>Ext:</td> <td> <input type="Text" name="ext2" size="6"> </td> </tr> <tr> <td>Email: </td> <td> <input type="Text" name="email2" size="35"> </td> </tr> </table> <table> <tr> <td colspan=4><b><br><br>Account Info:</b></td> </tr> <tr> <td>Accountant: </td> <td> <input type="Text" name="accnt" size="35"> </td> <td>QB Password:</td> <td> <input type="text" name="qb" size="10"> </td> </tr> <tr> <td> </td> <td><b>Services</b></td> <td colspan=2> </td> </tr> <tr> <td> </td> <td> <input type="checkbox" name="personal" value="checked">Personal </td> <td>Status</td> <td> <select name="status"> <option value="-" selected>-</option> <option value="Completed">Completed</option> <option value="In Review">In Review</option> <option value="In Process">In Process</option> <option value="Sent to GKM">Sent to GKM</option> <option value="Awaiting Source Docs">Awaiting Source Docs</option> <option value="On Hold/Past Due">On Hold/Past Due</option> <option value="Cancelled">Cancelled</option> </select> </td> </tr> <tr> <td> </td> <td> <input type="checkbox" name="business" value="checked">Business </td> <td>Status</td> <td> <select name="status2"> <option value="-" selected>-</option> <option value="Completed">Completed</option> <option value="In Review">In Review</option> <option value="In Process">In Process</option> <option value="Sent to GKM">Sent to GKM</option> <option value="Awaiting Source Docs">Awaiting Source Docs</option> <option value="On Hold/Past Due">On Hold/Past Due</option> <option value="Cancelled">Cancelled</option> </select> </td> </tr> <tr> <td> </td> <td> <input type="checkbox" name="payroll" value="checked">Payroll </td> <td>Status</td> <td> <select name="status3"> <option value="-" selected>-</option> <option value="Completed">Completed</option> <option value="In Review">In Review</option> <option value="In Process">In Process</option> <option value="Sent to GKM">Sent to GKM</option> <option value="Awaiting Source Docs">Awaiting Source Docs</option> <option value="On Hold/Past Due">On Hold/Past Due</option> <option value="Cancelled">Cancelled</option> </select> </td> </tr> <tr> <td> </td> <td> <input type="checkbox" name="retainer" value="checked">Retainer </td> <td>Status</td> <td> <select name="status4"> <option value="-" selected>-</option> <option value="Completed">Completed</option> <option value="In Review">In Review</option> <option value="In Process">In Process</option> <option value="Sent to GKM">Sent to GKM</option> <option value="Awaiting Source Docs">Awaiting Source Docs</option> <option value="On Hold/Past Due">On Hold/Past Due</option> <option value="Cancelled">Cancelled</option> </select> </td> </tr> <tr> <td>Notes: </td> <td colspan=3> <textarea name="newnotes" rows="5" cols="47"></textarea> </td> </tr> </table> <br> <input type="Submit" name="submit" value="Enter information"> </form> <?php } else echo "<br><br>Editing is disabled.\n"; } include ("include/footer.inc.php"); ?> -Brandon -
[SOLVED] One day it work the next nothing!
GreenSmurf replied to GreenSmurf's topic in PHP Coding Help
Should I post the new code for this topic seeing as how I solved it? -Brandon -
[SOLVED] One day it work the next nothing!
GreenSmurf replied to GreenSmurf's topic in PHP Coding Help
Ok, I fixed it but I ahve another request. Is it possible to add data to the begining of a column when you update without erasing the previous data? I would also like previous data to not be editable in anyway. Any suggestions? -Brandon -
[SOLVED] One day it work the next nothing!
GreenSmurf replied to GreenSmurf's topic in PHP Coding Help
This is the working code. <? include ("include/dbconnect.php"); include ("include/format.inc.php"); include ("include/header.inc.php"); ?> <h1>Edit / add address book entry</h1> <?php if($submit) { if(! $read_only) { $sql = "INSERT INTO $table (firstname, lastname, address, home, mobile, work, email, email2, bday, bmonth, byear, address2, phone2) VALUES ('$firstname','$lastname','$address','$home','$mobile','$work','$email','$email2','$bday','$bmonth','$byear', '$address2', '$phone2')"; $result = mysql_query($sql); $sql = "INSERT INTO address_in_groups SELECT LAST_INSERT_ID() id, group_id FROM group_list WHERE group_name = '".$group_name."'"; $result = mysql_query($sql); echo "<br><br>Information entered into address book,\n"; echo "<br><a href='edit$page_ext'>add next</a> or return to "; echo "<a href='index$page_ext'>home page</a>.<br>"; } else echo "<br><br>Editing is disabled.\n"; } else if($update) { if(! $read_only) { $sql="SELECT * FROM $base_from_where AND $table.id=$id"; $result = mysql_query($sql); $resultsnumber = mysql_numrows($result); if($resultsnumber > 0) { $sql = "UPDATE $table SET firstname='$firstname',lastname='$lastname',address='$address',home='$home',mobile='$mobile',work='$work',email='$email',email2='$email2',bday='$bday',bmonth='$bmonth',byear='$byear',address2 = '$address2', phone2 = '$phone2' WHERE id=$id"; $result = mysql_query($sql); // header("Location: view?id=$id"); echo "<br>Address book updated.\n"; echo "<br><a href='index$page_ext'>home page</a>"; } else { echo "<br>Invalid ID.\n"; echo "<br><a href='index$page_ext'>home page</a>"; } } else echo "<br><br>Editing is disabled.\n"; } else if($id) { if(! $read_only) { $result = mysql_query("SELECT * FROM $base_from_where AND $table.id=$id",$db); $myrow = mysql_fetch_array($result); ?> <form method="post" action="edit<? echo $page_ext; ?>"> <table width="380" border="0" cellspacing="1" cellpadding="1"> <tr> <td> <input type="hidden" name="id" value="<?php echo $myrow["id"]?>"> Firstname: </td> <td> <input type="Text" name="firstname" size="35" value="<?php echo $myrow["firstname"]?>"> </td> </tr> <tr> <td>Lastname:</td> <td> <input type="Text" name="lastname" size="35" value="<?php echo $myrow["lastname"]?>"> </td> </tr> <tr> <td>Address: </td> <td> <textarea name="address" rows="5" cols="35"><?php echo $myrow["address"]?></textarea> </td> </tr> <tr> <td>Telephone:</td> <td> </td> </tr> <tr> <td>Home:</td> <td> <input type="Text" name="home" value="<?php echo $myrow["home"]?>"> </td> </tr> <tr> <td>Mobile:</td> <td> <input type="Text" name="mobile" value="<?php echo $myrow["mobile"]?>"> </td> </tr> <tr> <td>Work: </td> <td> <input type="Text" name="work" value="<?php echo $myrow["work"]?>"> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td>Email:</td> <td> <input type="Text" name="email" size="35" value="<?php echo $myrow["email"]?>"> </td> </tr> <tr> <td>Email2:</td> <td> <input type="Text" name="email2" size="35" value="<?php echo $myrow["email2"]?>"> </td> </tr> <tr> <td>Birthday:</td> <td> <select name="bday"> <option value="<?php echo $myrow["bday"]?>" selected><?php echo ($myrow["bday"] == 0?"-":$myrow["bday"]) ?></option> <option value="0">-</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="bmonth"> <option value="<?php echo $myrow["bmonth"] ?>" selected><?php echo $myrow["bmonth"]?></option> <option value="-">-</option> <option value="January">January</option> <option value="February">February</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <input type="text" name="byear" size="4" maxlength="4" value="<?php echo $myrow["byear"]?>"> </td> </tr> <tr> <td colspan=2><b><br><br>Secondary</b></td> </tr> <tr> <td>Address: </td> <td> <textarea name="address2" rows="5" cols="35"><?php echo $myrow["address2"]?></textarea> </td> </tr> <tr> <td>Home:</td> <td> <input type="Text" name="phone2" value="<?php echo $myrow["phone2"]?>"> </td> </tr> </table> <br> <input type="Submit" name="update" value="Update information"> </form> <br> <form method="get" action="delete<? echo $page_ext; ?>"> <input type="hidden" name="id" value="<?php echo $myrow["id"]?>"> <input type="Submit" name="update" value="Delete information"> </form> <? } else echo "<br><br>Editing is disabled.\n"; } else { if(! $read_only) { ?> <form method="post" action="edit<? echo $page_ext; ?>"> <table width="380" border="0" cellspacing="1" cellpadding="1"> <tr> <td> <input type="hidden" name="id" value="<?php echo $myrow["id"]?>"> Firstname:</td> <td> <input type="Text" name="firstname" size="35"> </td> </tr> <tr> <td>Lastname: </td> <td> <input type="Text" name="lastname" size="35"> </td> </tr> <tr> <td>Address: </td> <td> <textarea name="address" rows="5" cols="35"></textarea> </td> </tr> <tr> <td>Telephone:</td> <td> </td> </tr> <tr> <td>Home:</td> <td> <input type="Text" name="home"> </td> </tr> <tr> <td>Mobile: </td> <td> <input type="Text" name="mobile"> </td> </tr> <tr> <td>Work:</td> <td> <input type="Text" name="work"> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td>Email: </td> <td> <input type="Text" name="email" size="35"> </td> </tr> <tr> <td>Email2: </td> <td> <input type="Text" name="email2" size="35"> </td> </tr> <tr> <td>Birthday:</td> <td> <select name="bday"> <option value="0" selected>-</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select name="bmonth"> <option value="-" selected>-</option> <option value="January">January</option> <option value="February">February</option> <option value="March">March</option> <option value="April">April</option> <option value="May">May</option> <option value="June">June</option> <option value="July">July</option> <option value="August">August</option> <option value="September">September</option> <option value="October">October</option> <option value="November">November</option> <option value="December">December</option> </select> <input type="text" name="byear" size="4" maxlength="4"> </td> </tr> <tr> <td colspan=2><b><br><br>Secondary</b></td> </tr> <tr> <td>Address: </td> <td> <textarea name="address2" rows="5" cols="35"></textarea> </td> </tr> <tr> <td>Home:</td> <td> <input type="Text" name="phone2"> </td> </tr> </table> <br> <input type="Submit" name="submit" value="Enter information"> </form> <? } else echo "<br><br>Editing is disabled.\n"; } include ("include/footer.inc.php"); ?> Thank you. -Brandon