Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
T

Tichaona J

@Tichaona J
About
Posts
41
Topics
25
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • User input varification
    T Tichaona J

    I’ve written code (below) of which receives posted fields data on to the acknowledgement page (Subscribe page > Acknowledge page), however the code is not working as expected so I’ve removed the other code (mainly the sanitizing of user input) and left the code were the users input is checked for empty spaces. This still isn’t working...I’m a rooky, so any help is much appreciated

     if($\_POST\['username'\] === "" ||$\_POST\['userfirstname'\]=== ""|| $\_POST\['usersecondname'\]=== ""||$\_POST\['useremail'\]=== ""||$\_POST\['userpassword'\]=== ""||
    $\_POST\['userpasswordr'\]=== "")
    
    {	
    
    $arr\_fields = array("$\_POST\['username'\]", "$\_POST\['userfirstname'\]", "$\_POST\['usersecondname'\]", "$\_POST\['useremail'\]",
                        "$\_POST\['userpassword'\]", "$\_POST\['userpasswordr'\]");
    
    foreach($arr\_fields as $arr\_field)
    {
    
    	if($arr\_field == "")
    		{
    			$arr\_field = "missing";
    
    		}
    
    }
    
    	$var\_username=			$\_POST\['username'\];
    	$var\_userfirstname=		$\_POST\['userfirstname'\];
    	$var\_usersecondname=		$\_POST\['usersecondname'\];
    	$var\_useremail=			$\_POST\['useremail'\];
    	$var\_userpassword=		$\_POST\['userpassword'\];
    	$var\_userpassword\_repeat= 	$\_POST\['userpasswordr'\];
    	
    	$arr\_fields\_processed = array("$var\_username", "$var\_userfirstname", "$var\_usersecondname", "$var\_useremail",
    					 "$var\_userpassword", "$var\_userpassword\_repeat");
    	
    	header ("location: subscribe.php?arr\_fields\_processed");
    
     } else 
    
    
     	{
    
    	
     	 	//sanitize code...
    	
     	}
    

    :confused:

    Web Development php data-structures help question

  • Form submit error message
    T Tichaona J

    Thanks...That worked... :)

    Web Development help question

  • Form submit error message
    T Tichaona J

    I am trying to get my code to check the “username” field and print an error message letting the user know that they left a field blank. Now before all I had was the below code of which it worked in part, in the sense that the below code was executed when the submit button was clicked on and when the page was refreshed.

                   if (isset($\_POST\['username'\])) {
                                        
                               emptyField();
                                    
                                         }                           
                                             
                          
                                 function emptyField()
                                    {
                                      $var1 = "**\*Field missing entry...**";
                                     echo $var1;
                                    }
    

    To fix this I the added the below code, which now meant that the code only worked if the user clicked on the submit button and didn’t work if the page is refreshed. However I’ve also noticed that even when there is text in the “username” field and say the user got there password wrong (not proceeding to the next page), it simply cleared all fields and printed “*Field missing entry...*” Why is this and how do I sort this out…?

    *Field missing entry...";
    echo $var1;
    }

    Web Development help question

  • Time and date
    T Tichaona J

    Am not sure what I’ve done wrong. The below code is supposed to show the time and date as Time|Date: 16:08:24 31/3/2013, however its now showing up as Time|Date: 16:08:24 0/3/2013…

    <script>
    function startTime()
    {
    var today=new Date();
    var d=today.getDay(); //---Day Sunday
    var dt=today.getDate(); //---Date 1-31
    var mt=today.getMonth() + 1; //---Month
    var y=today.getFullYear();//---Year
    var h=today.getHours(); //---Hours
    var m=today.getMinutes(); //---Mintutes
    var s=today.getSeconds(); //---Seconds
    // add a zero in front of numbers<10
    m=checkTime(m);
    s=checkTime(s);
    document.getElementById('txt').innerHTML= "Time|Date:"+" "+h+":"+m+":"+s+ " " + d+"/"+mt+"/"+y;
    t=setTimeout(function(){startTime()},500);
    }

    function checkTime(i)
    {
    if (i<10)
    {
    i="0" + i;
    }
    return i;
    }
    </script>

    Note: Everything else is fine except for the date, what with it bring up '0' instead of '31'

    JavaScript tools

  • Slide show
    T Tichaona J

    I’m trying to get my website to show images one after the other using java script I got from www.javascriptkit.com/howto/show2.shtml and have followed there example as closely as I can but with no luck.

    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Acrele - Home</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />

    <script type="text/javascript">

        var image1=new Image()
        image1.src="16.jpg"
    
        var image2=new Image()
        image2.src="employee-training.jpg"
    
        var image3=new Image()
        image3.src="Real\_Estate\_Investment\_Education.jpg"
    
        var image4=new Image()
        image4.src="Unti2tled.jpg"
    
        var image5=new Image()
        image5.src="Untitled.jpg"
    
        var image6=new Image()
        image6.src="zclassroom.jpg"
    

    </script>

    </head>

    2. Added the html code were I want the image to show:

                                    ![](16.jpg)
    

    3. Edited there javascript accordingly to the number of images I’m using:

                                    ![](16.jpg)
    
                                    <script>
                                    var step=1;
    
                                  //if browser does not support the image object, exit.
                                  var img = document.getElementById('slide');
                                  img.src = "image" + step + ".src";
                                  console.log(img.src);
                                  if (step < 6) step++;
                                      else step = 1;
                                      //call function "slideit()" every 2.5 seconds
                                      setTimeout(slideit, 3500);
    
    
                             </script>
    

    This isn’t working, it onl

    JavaScript java javascript html com tools

  • Socket programming
    T Tichaona J

    Thanks guys...With you hints and tips I have figured it out. Part of the solution (the code any) came from this site: msdn library Once again thanks... :) :) :)

    C# sysadmin json help

  • Socket programming
    T Tichaona J

    I have since tried to put the strings into an arraylist but question now is how do you convert the array list into bytes, cause this doesn't work:

    //Add items to the arraylist
    patient.Add(Pname);
    patient.Add(Pdob);
    patient.Add(PnhsNo);
    patient.Add(Paddress);
    patient.Add(PmedicalCon);
    patient.Add(pcallOutDetails);

                byte\[\] forwardMessage = Encoding.ASCII.GetBytes(patient);
                
                sock.Send(forwardMessage);
    
                
                sock.Shutdown(SocketShutdown.Both);
                sock.Close();
    
    C# sysadmin json help

  • Socket programming
    T Tichaona J

    Hi I have two application which I have managed to get them to exchange data however, I would like to be able to sort the data out when it is recieved by the other end (server). On the client side, the data is taken from the various forms and sent as below:

                 String Pname = LblName.Text;
                String Pdob = LblDOB.Text;
                String PnhsNo = LblNHSno.Text;
                String Paddress = RtxtBxAddre.Text;
                String PmedicalCon = RtxtBxMedCon.Text;
                String pcallOutDetails = RTxtBxCallOut.Text;
    
                byte\[\] forwardMessage = Encoding.ASCII.GetBytes(Pname + Pdob + PnhsNo + Paddress + PmedicalCon + pcallOutDetails);
               sock.Send(forwardMessage);
    
                sock.Shutdown(SocketShutdown.Both);
                sock.Close();
    

    On the other end I would now like to take each item and display it in a form, so "Pname" is taken when received and displayed in a text box and then same with the rest of the data. Unlike displaying it in a message box like I have done below:

    Socket listener = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
    listener.Bind(new IPEndPoint(IPAddress.Any, 2112));
    listener.Listen(10);

           Socket socket = listener.Accept();
           string receivedValue = string.Empty;
    
           
                     byte\[\] receivedBytes = new byte\[1024\];
                      int numBytes = socket.Receive(receivedBytes);
                          
                              receivedValue = Encoding.ASCII.GetString(receivedBytes,0, numBytes);
                             
                                    MessageBox.Show(receivedValue);
                                                                    
                                    listener.Close();
    

    Help....:confused:

    C# sysadmin json help

  • SQL statement
    T Tichaona J

    Thanks it works great... :)

    Database database java architecture help learning

  • SQL statement
    T Tichaona J

    Hi I am using a SQL statement to access data from a database, if I hardcode a specific name in the field I get, the name being searched for is returned and displayed. Of-course this isn't a convient way of doing things so I introduced a text box to take in the data, store it in a variable then, this is were my problem lies, I try and used my variable in the SQL statement but it does not work. My code is as below: static private string GetConnectionString() { return "Driver={Microsoft Access Driver (*.mdb)};" + "Dbq=c:\\Users\\Tichaona\\Documents\\My Dropbox\\SET10101 Software Architecture\\coursework1\\patients.mdb;Uid=java;Pwd=password;"; } private void BtnSearch_Click(object sender, EventArgs e) { String nameSearch = TxtBxName.Text; <<

    Database database java architecture help learning

  • Writting to a database
    T Tichaona J

    Thanks for the answer, however just because something seems simple to you doesn't mean it will be to the next arrogent SB.

    Database database tutorial question

  • Writting to a database
    T Tichaona J

    I have my database called patients.mdb and I am using the below code to read from it (part of the code): OdbcDataReader reader = command.ExecuteReader(); while (reader.Read()) { rTxtBxMC.Text = Convert.ToString( reader[0]); } reader.Close(); How to you write to a database of this type?

    Database database tutorial question

  • Unit testing
    T Tichaona J

    Right I see what your saying...First of all I should have pointed out that I am working with WPF hence use a nullable boolean to get the return value of a dialog box, the other way of calling a dialog box does not seem to work when developing a WPF based app. Secondly I used this as am example which I have to say after the response I got from fock was a bad example of which I was hoping fock would use it to illustrate how to test a method that does not return anything...Please bear in mind that I am a rooky,so if I say something that seems obvious to you, may not be the case with me...

    C# tutorial question csharp visual-studio com

  • Unit testing
    T Tichaona J

    Just watching this VSTS 2008 Unit Testing 1 of 1 lets you know how to test methods that return something, my question here is how do you test methods in Visual Studio 2008 that don't return any value? For example:

    private void BtnLoad_Click(object sender, RoutedEventArgs e)
    {
    //Declare a new file dialog box
    OpenFileDialog dlg = new OpenFileDialog();

            //Set properties for the dialog...
            dlg.Title = "Select one or more media files";
            dlg.Multiselect = IsEnabled;
            dlg.Filter = "Media files(\*.mp3;\*.wav;\*.wma;\*.avi;\*.mp4;\*.mpg;\*.wmv)|\*.mp3;\*.wav;\*.wma;\*.avi;\*.mp4;\*.mpg;\*.wmv|All files(\*.\*)|\*.\*";
    
            //The result of the open file dialog is either true or false (didn't work).
            Nullable<bool> result = dlg.ShowDialog();
    
            //If the result of the open file dialog was true then....
            if (result == true)
            {
                string\[\] files;
    
                files = dlg.FileNames;
    
                //Add each file into the list box
                foreach (string file in files)
                {
                    lstBxList.Items.Add(file);
                }                
            }
    
        }
    
    C# tutorial question csharp visual-studio com

  • Server based on AsyncCallback not running as expected
    T Tichaona J

    Hi All I have a server that starts up as part of my application (when the application InitializeComponent()), as below: public Window1() { InitializeComponent(); ...other code //Start the server... connectionAccept(); } This calls the below code: private void connectionAccept() { try { listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPEndPoint LocalIP = new IPEndPoint(IPAddress.Any, 2112); listener.Bind(LocalIP); listener.Listen(0); listener.BeginAccept(new AsyncCallback(OnClientConnect), null); }//End of try catch (SocketException se) { MessageBox.Show(se.Message); }//End of catch }// End of connectionAccept method //On client call.... public void OnClientConnect(IAsyncResult asyn) { try { otherListener[numberOfClients] = listener.EndAccept(asyn); WaitForData(otherListener[numberOfClients]); ++numberOfClients; String strData = Convert.ToString(numberOfClients); MessageBox.Show(strData); listener.BeginAccept(new AsyncCallback(OnClientConnect), null); } catch (ObjectDisposedException) { System.Diagnostics.Debugger.Log(0, "1", "\n OnClientConnection: Socket has been closed\n"); }//End of first catch catch (SocketException se) { MessageBox.Show(se.Message); }//End of second catch }//End of OnClientConnect method public class SocketPacket { public System.Net.Sockets.Socket currentSoc; public byte[] dataBuffer = new byte[0]; }//End of Socket packet public void WaitForData(System.Net.Sockets.Socket soc) { try { if (pfnListnerCallBack == null) { pfnListnerCallBack = new AsyncCallback(OnDataReceived); SocketPacket socPkt = new SocketPacket(); socPkt.

    C# csharp sysadmin debugging

  • button text to image
    T Tichaona J

    Apologies - I should have specified that I am developing a WPF application. There doesn't seem to bean option to add an image, unless I am just missing it....:confused:

    C# csharp visual-studio tutorial question

  • button text to image
    T Tichaona J

    Apologies - I should have specified that I am developing a WPF application. There doesn't seem to be an option to add an image, unless I am just missing it....Confused

    C# csharp visual-studio tutorial question

  • Multilingual Report [modified]
    T Tichaona J

    Syed Shahid Hussain - others as well as I are not too sure what exactly you are trying to do.Try restructing your question, because at the moment it doesn't make much sense...Are you trying to develop an application that will convert from on currency to another? Please give more details so that we can better assist you...

    C# csharp help tutorial question

  • button text to image
    T Tichaona J

    Hi - as we all know when developing an application in Visual studio (assumming c#), you can change a controls property like for example a buttons text property to reflect its function which is all very nice. But what happens when you say don't want to change the text property, infact you done even want any text there? All you want is a logo instead, how do you go about getting a logo on a button, give that it does not have a image property?

    C# csharp visual-studio tutorial question

  • Chars received
    T Tichaona J

    Hate to break it you, but this had no effect.

    C#
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups